<br />
<b>Warning</b>:  Undefined array key "global_protection_id" in <b>/home/wikitechy/public_html/interview-questions/wp-content/plugins/content-protector/inc/class-ps-rest-handler.php</b> on line <b>51</b><br />
{"id":4001,"date":"2022-03-26T10:47:23","date_gmt":"2022-03-26T10:47:23","guid":{"rendered":"https:\/\/www.wikitechy.com\/interview-questions\/?p=4001"},"modified":"2022-05-04T07:16:09","modified_gmt":"2022-05-04T07:16:09","slug":"what-are-the-types-of-react-component","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-types-of-react-component\/","title":{"rendered":"What are the types of React component ?"},"content":{"rendered":"<ul>\n<li style=\"text-align: justify;\">It is one of the core building blocks of React.<\/li>\n<li style=\"text-align: justify;\">In React we develop every application and it will be made of pieces, that is known as component.<\/li>\n<li style=\"text-align: justify;\">Components make the task of building UIs much easier.<\/li>\n<li style=\"text-align: justify;\">We see that UI broken down into multiple individual pieces called components and work on them independently and merge them all in a parent component which will be your final UI.<\/li>\n<li style=\"text-align: justify;\">React Component basically return a piece of JSX code that tells what should be rendered on the screen.<\/li>\n<li style=\"text-align: justify;\">In React component there are two types:\n<ul>\n<li>Functional Components<\/li>\n<li>Class Components<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone wp-image-4027 size-full\" src=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/types-of-react-components-1.png\" alt=\"\" width=\"748\" height=\"264\" srcset=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/types-of-react-components-1.png 748w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/types-of-react-components-1-300x106.png 300w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/types-of-react-components-1-390x138.png 390w\" sizes=\"(max-width: 748px) 100vw, 748px\" \/><\/p>\n<h4 id=\"functional-components\" style=\"text-align: justify;\">Functional Components<\/h4>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-4278\" src=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/components-in-components.gif\" alt=\"\" width=\"1265\" height=\"644\" \/><\/p>\n<ul style=\"text-align: justify;\">\n<li>Functional components are simply JS functions.<\/li>\n<li>In React we can create Functional Component by writing a JS function.<\/li>\n<li>To create React app efficient, we use functional component only when we are sure that our component does not require to interact with any other components.<\/li>\n<li>It does not require data from other components.<\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><strong>For example,<\/strong><\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-markup code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-markup code-embed-code\">const Democomponent=()=&gt;<br\/><br\/>\u00a0\u00a0\u00a0 {<br\/><br\/>\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return &lt;h1&gt;Welcome to Kaashiv!&lt;\/h1&gt;;<br\/><br\/>\u00a0\u00a0\u00a0 }<\/code><\/pre> <\/div>\n<h4 id=\"\"><img decoding=\"async\" class=\"alignnone size-full wp-image-4279 aligncenter\" src=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/components-in-files.gif\" alt=\"\" width=\"1271\" height=\"569\" \/><\/h4>\n<h4 id=\"class-components\" style=\"text-align: justify;\">Class Components<\/h4>\n<ul>\n<li style=\"text-align: justify;\">The class components are much like the functional component but has a few additional capabilities that makes class component a little more complicated than the functional components.<\/li>\n<li style=\"text-align: justify;\">The class components can work with each other where functional components are not aware of the other components in your program.<\/li>\n<li style=\"text-align: justify;\">From one class component to other class components, we can pass the data.<\/li>\n<li style=\"text-align: justify;\">In React we use JavaScript ES6 classes to create class-based components.<\/li>\n<\/ul>\n<p><strong>For example,<\/strong><\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-markup code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-markup code-embed-code\">class Democomponent extends React.Component<br\/>   {<br\/>       render(){<br\/>             return &lt;h1&gt;Welcome to Kaashiv!&lt;\/h1&gt;;<br\/>      }<br\/>  }<\/code><\/pre> <\/div>\n","protected":false},"excerpt":{"rendered":"<p>It is one of the core building blocks of React. In React we develop every application and it will be made of pieces, that is known as component. Components make the task of building UIs much easier. We see that UI broken down into multiple individual pieces called components and work on them independently and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"passster_activate_protection":false,"passster_protect_child_pages":"","passster_protection_type":"password","passster_password":"","passster_activate_overwrite_defaults":"","passster_headline":"","passster_instruction":"","passster_placeholder":"","passster_button":"","passster_id":"","passster_activate_misc_settings":"","passster_redirect_url":"","passster_hide":"no","passster_area_shortcode":"","gtb_hide_title":false,"gtb_wrap_title":false,"gtb_class_title":"","gtb_remove_headerfooter":false,"footnotes":""},"categories":[16542],"tags":[16594,16755,16756,16754,16749,16750,16746,16747,16752,16748,16753,16751],"class_list":["post-4001","post","type-post","status-publish","format-standard","hentry","category-reactjs","tag-class-component-react","tag-functional-component-react","tag-react-component-example","tag-react-component-lifecycle","tag-react-components","tag-react-top-level-api-components-and-its-types-in-reactjs-what-are-the-types-of-components-available-in-react","tag-reactjs-components","tag-types-of-react-components","tag-types-of-react-js","tag-what-are-the-types-of-components","tag-what-is-component-in-react","tag-what-is-the-type-of-a-react-component"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What are the types of React component ? - React Interview Questions<\/title>\n<meta name=\"description\" content=\"What are the types of React component ? - React Interview Questions - It is one of the core building blocks of React.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-types-of-react-component\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What are the types of React component ? - React Interview Questions\" \/>\n<meta property=\"og:description\" content=\"What are the types of React component ? - React Interview Questions - It is one of the core building blocks of React.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-types-of-react-component\/\" \/>\n<meta property=\"og:site_name\" content=\"Wikitechy\" \/>\n<meta property=\"article:published_time\" content=\"2022-03-26T10:47:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-05-04T07:16:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/types-of-react-components-1.png\" \/>\n<meta name=\"author\" content=\"webmaster\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"webmaster\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-types-of-react-component\/\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-types-of-react-component\/\",\"name\":\"What are the types of React component ? - React Interview Questions\",\"isPartOf\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-types-of-react-component\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-types-of-react-component\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/types-of-react-components-1.png\",\"datePublished\":\"2022-03-26T10:47:23+00:00\",\"dateModified\":\"2022-05-04T07:16:09+00:00\",\"author\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4\"},\"description\":\"What are the types of React component ? - React Interview Questions - It is one of the core building blocks of React.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-types-of-react-component\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-types-of-react-component\/#primaryimage\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/types-of-react-components-1.png\",\"contentUrl\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/types-of-react-components-1.png\",\"width\":748,\"height\":264},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/\",\"name\":\"Wikitechy\",\"description\":\"Interview Questions\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4\",\"name\":\"webmaster\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"caption\":\"webmaster\"},\"sameAs\":[\"https:\/\/www.wikitechy.com\/interview-questions\"],\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/author\/webmaster\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What are the types of React component ? - React Interview Questions","description":"What are the types of React component ? - React Interview Questions - It is one of the core building blocks of React.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-types-of-react-component\/","og_locale":"en_US","og_type":"article","og_title":"What are the types of React component ? - React Interview Questions","og_description":"What are the types of React component ? - React Interview Questions - It is one of the core building blocks of React.","og_url":"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-types-of-react-component\/","og_site_name":"Wikitechy","article_published_time":"2022-03-26T10:47:23+00:00","article_modified_time":"2022-05-04T07:16:09+00:00","og_image":[{"url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/types-of-react-components-1.png"}],"author":"webmaster","twitter_card":"summary_large_image","twitter_misc":{"Written by":"webmaster","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-types-of-react-component\/","url":"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-types-of-react-component\/","name":"What are the types of React component ? - React Interview Questions","isPartOf":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-types-of-react-component\/#primaryimage"},"image":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-types-of-react-component\/#primaryimage"},"thumbnailUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/types-of-react-components-1.png","datePublished":"2022-03-26T10:47:23+00:00","dateModified":"2022-05-04T07:16:09+00:00","author":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4"},"description":"What are the types of React component ? - React Interview Questions - It is one of the core building blocks of React.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-types-of-react-component\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/reactjs\/what-are-the-types-of-react-component\/#primaryimage","url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/types-of-react-components-1.png","contentUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/03\/types-of-react-components-1.png","width":748,"height":264},{"@type":"WebSite","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website","url":"https:\/\/www.wikitechy.com\/interview-questions\/","name":"Wikitechy","description":"Interview Questions","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4","name":"webmaster","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","caption":"webmaster"},"sameAs":["https:\/\/www.wikitechy.com\/interview-questions"],"url":"https:\/\/www.wikitechy.com\/interview-questions\/author\/webmaster\/"}]}},"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4001","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/comments?post=4001"}],"version-history":[{"count":4,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4001\/revisions"}],"predecessor-version":[{"id":4280,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4001\/revisions\/4280"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/media?parent=4001"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/categories?post=4001"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/tags?post=4001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}