{"id":1365,"date":"2023-05-25T12:37:30","date_gmt":"2023-05-25T11:37:30","guid":{"rendered":"https:\/\/codeflarelimited.com\/blog\/?p=1365"},"modified":"2023-05-25T12:37:31","modified_gmt":"2023-05-25T11:37:31","slug":"conditional-rendering-in-react","status":"publish","type":"post","link":"https:\/\/codeflarelimited.com\/blog\/conditional-rendering-in-react\/","title":{"rendered":"Conditional Rendering in React"},"content":{"rendered":"\n<p>Conditional rendering is a crucial concept in React, a popular JavaScript library for building user interfaces. It allows you to control the display of components based on certain conditions, enabling dynamic and interactive web applications. <\/p>\n\n\n\n<p>For instance, if you&#8217;re building an application that requires admin privileges to perform some task, instead having different pages for the different administrators, you can choose to conditionally render action buttons based on privilege the admin user has. If the current user does not have delete privilege, then he will not see the delete action button and so on and so forth.<\/p>\n\n\n\n<p>In this article, we will delve into the world of conditional rendering in React, exploring its fundamental principles, best practices, and various techniques to handle conditional logic effectively. Whether you&#8217;re a beginner or an experienced React developer, this guide will equip you with the knowledge and skills to harness the power of conditional rendering and build highly responsive user interfaces.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-first-understand-the-concept-of-conditional-rendering\">First Understand the Concept of Conditional Rendering<\/h2>\n\n\n\n<p>In React, conditional rendering refers to the process of deciding whether to render a particular component or its contents based on certain conditions. This approach allows developers to create UI components that adapt to changing data or user interactions. By employing conditional rendering, you can control the visibility, behavior, and appearance of different elements in your application, leading to a more intuitive and personalized user experience, like in the scenario I pointed out earlier.<\/p>\n\n\n\n<p>Conditional rendering in React typically revolves around conditional statements, such as <code><strong><em>if<\/em><\/strong><\/code>, <code><strong><em>else<\/em><\/strong><\/code>, and <code><em><strong>ternary operators<\/strong><\/em><\/code>, that evaluate a condition and determine which components or elements should be rendered. React&#8217;s declarative nature enables developers to express these conditions seamlessly, making code more readable and maintainable.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conditional-rendering-techniques\">Conditional Rendering Techniques<\/h2>\n\n\n\n<p>React provides multiple techniques for conditional rendering, catering to different use cases and preferences. Let&#8217;s explore some of the most commonly used techniques:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>If\/Else Statements<\/strong>: You can use JavaScript&#8217;s <code>if<\/code> and <code>else<\/code> statements to conditionally render components. By evaluating a condition, you can render different components based on the result.<\/li>\n\n\n\n<li><strong>Ternary Operator<\/strong>: The ternary operator (<code>condition ? true : false<\/code>) is a concise way to perform conditional rendering. It allows you to render one component or another based on the condition.<\/li>\n\n\n\n<li><strong>&amp;&amp; Operator<\/strong>: React supports using the logical AND operator (<code>&amp;&amp;<\/code>) to conditionally render a component. If the condition evaluates to <code>true<\/code>, the component is rendered; otherwise, it&#8217;s skipped.<\/li>\n\n\n\n<li><strong>Switch Statements<\/strong>: For more complex conditions, you can employ JavaScript&#8217;s <code>switch<\/code> statement to conditionally render components. By associating each case with a specific component, you can render different components based on the condition&#8217;s value.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conditional-rendering-using-if-else-statements\">Conditional Rendering Using If\/else Statements<\/h2>\n\n\n\n<p>Let&#8217;s see an example of the most basic form of conditional rendering using <strong><em>if\/else <\/em><\/strong>statements. Consider a scenario where we want to display a greeting message based on the time of day. Here&#8217;s how you can achieve this with conditional rendering:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"jsx\" class=\"language-jsx\">import React, {Component} from 'react';\n\nclass Greeting extends Component {\n  const currentTime = new Date();\n  const hour = currentTime.getHours();\n  \n  let message;\n  if (hour &lt; 12) {\n    message = 'Good morning!';\n  } else if (hour &lt; 18) {\n    message = 'Good afternoon!';\n  } else {\n    message = 'Good evening!';\n  }\n  \n  render(){\n  return &lt;div>{message}&lt;\/div>;\n }\n}\n\nexport default Greeting;\n<\/code><\/pre>\n\n\n\n<p>In this example, we obtain the current hour using the <code><strong>getHours()<\/strong><\/code> method and assign the appropriate message to the <code>message<\/code> variable based on the hour&#8217;s value. The message is then rendered inside a <code>&lt;div><\/code> element.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conditional-rendering-using-ternary-operators\">Conditional Rendering Using Ternary Operators<\/h2>\n\n\n\n<p>The ternary operator provides a concise way to perform conditional rendering in React. Let&#8217;s extend the previous example using the ternary operator:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"jsx\" class=\"language-jsx\">import React, {Component} from 'react';\n\nclass Greeting extends Component {\n  const currentTime = new Date();\n  const hour = currentTime.getHours();\n  \n const message = hour &lt; 12 ? 'Good morning!' : hour &lt; 18 ? 'Good   afternoon!' : 'Good evening!';\n  \n  render(){\n  return &lt;div>{message}&lt;\/div>;\n}\n}\n\nexport default Greeting;\n<\/code><\/pre>\n\n\n\n<p>In this updated version, we utilize the ternary operator to evaluate the condition and assign the appropriate message to the <code>message<\/code> variable in a single line of code. This approach offers a more concise and readable alternative to if\/else statements for simple conditions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conditional-rendering-with-logical-and-operator\">Conditional Rendering with Logical AND Operator<\/h2>\n\n\n\n<p>The <a href=\"https:\/\/codeflarelimited.com\/blog\/logical-operators\/\" target=\"_blank\" rel=\"noreferrer noopener\">logical <strong>AND<\/strong> operator<\/a> (<code><strong>&amp;&amp;<\/strong><\/code>) can also be used for conditional rendering in React. Let&#8217;s consider a scenario where we want to render a button only if a user is logged in:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"jsx\" class=\"language-jsx\">import React, {Component} from 'react';\nconst isLoggedIn = true;\n\nclass App extends Component {\n  \n  render(){\n  return (\n    &lt;div>\n      &lt;h1>Welcome to the App!&lt;\/h1>\n      {isLoggedIn &amp;&amp; &lt;button>Logout&lt;\/button>}\n    &lt;\/div>\n  );\n}\n}\n\nexport default App;\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conditional-rendering-with-component-composition\">Conditional Rendering with Component Composition<\/h2>\n\n\n\n<p>React&#8217;s component composition allows us to create more modular and reusable code. Let&#8217;s consider the admin privilege example where we want to render a specific component based on a user&#8217;s role.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"jsx\" class=\"language-jsx\">import React, {Component} from 'react';\n\nclass Dashboard extends Component {\n\n constructor(props){\n super(props);\n this.state = {\n useHasAccess: \"admin\"\n }\n}\n UserDashboard() {\n  return &lt;div>Welcome, User!&lt;\/div>;\n}\n AdminDashboard() {\n  return &lt;div>Welcome, Admin!&lt;\/div>;\n}\n\n  render(){\n  const { userRole } = this.state;\n  return (\n    &lt;div>\n      &lt;h1>Dashboard&lt;\/h1>\n      {userRole === 'admin' ? &lt;AdminDashboard \/> : &lt;UserDashboard \/>}\n    &lt;\/div>\n  );\n}\n}\n\nexport default Dashboard;\n<\/code><\/pre>\n\n\n\n<p>In this example, we define two separate functional components: <code><strong>AdminDashboard<\/strong><\/code> and <code><strong>UserDashboard<\/strong><\/code>. The <code>Dashboard<\/code> component receives the <code>userRole<\/code> as a prop and renders the appropriate dashboard component based on the value of <code><strong>userRole<\/strong><\/code>. This pattern allows for flexible and reusable code by composing different components based on conditions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2>\n\n\n\n<p>Conditional rendering is a powerful feature in React that allows you to create dynamic and interactive user interfaces. By mastering the various techniques and best practices outlined in this guide, you can effectively handle conditional logic, resulting in more flexible, responsive, and maintainable code. As you continue to explore React and its ecosystem, keep experimenting with conditional rendering to enhance the user experience and build exceptional web applications.<\/p>\n\n\n\n<p><a href=\"https:\/\/origamisuite.dev\/blog\/2023\/04\/30\/react-native-flexbox\/\" target=\"_blank\" rel=\"noreferrer noopener\">React Native Flexbox<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Conditional rendering is a crucial concept in React, a popular JavaScript library for building user interfaces. It allows<\/p>\n","protected":false},"author":1,"featured_media":1366,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[73,98],"tags":[],"class_list":["post-1365","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-react-js","category-softare-development"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Conditional Rendering in React<\/title>\n<meta name=\"description\" content=\"Conditional rendering is a crucial concept in React, a popular JavaScript library for building user interfaces\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/codeflarelimited.com\/blog\/conditional-rendering-in-react\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Conditional Rendering in React\" \/>\n<meta property=\"og:description\" content=\"Conditional rendering is a crucial concept in React, a popular JavaScript library for building user interfaces\" \/>\n<meta property=\"og:url\" content=\"https:\/\/codeflarelimited.com\/blog\/conditional-rendering-in-react\/\" \/>\n<meta property=\"article:author\" content=\"https:\/\/facebook.com\/codeflretech\" \/>\n<meta property=\"article:published_time\" content=\"2023-05-25T11:37:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-05-25T11:37:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/05\/Screen-Shot-2023-05-25-at-12.36.41-PM.png\" \/>\n\t<meta property=\"og:image:width\" content=\"932\" \/>\n\t<meta property=\"og:image:height\" content=\"486\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"codeflare\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@codeflaretech\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"TechArticle\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/conditional-rendering-in-react\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/conditional-rendering-in-react\\\/\"},\"author\":{\"name\":\"codeflare\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#\\\/schema\\\/person\\\/7e65653d49add95629f8c1053c5cd76a\"},\"headline\":\"Conditional Rendering in React\",\"datePublished\":\"2023-05-25T11:37:30+00:00\",\"dateModified\":\"2023-05-25T11:37:31+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/conditional-rendering-in-react\\\/\"},\"wordCount\":759,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/conditional-rendering-in-react\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/05\\\/Screen-Shot-2023-05-25-at-12.36.41-PM.png\",\"articleSection\":[\"react js\",\"softare development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/conditional-rendering-in-react\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/conditional-rendering-in-react\\\/\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/conditional-rendering-in-react\\\/\",\"name\":\"Conditional Rendering in React\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/conditional-rendering-in-react\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/conditional-rendering-in-react\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/05\\\/Screen-Shot-2023-05-25-at-12.36.41-PM.png\",\"datePublished\":\"2023-05-25T11:37:30+00:00\",\"dateModified\":\"2023-05-25T11:37:31+00:00\",\"description\":\"Conditional rendering is a crucial concept in React, a popular JavaScript library for building user interfaces\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/conditional-rendering-in-react\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/conditional-rendering-in-react\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/conditional-rendering-in-react\\\/#primaryimage\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/05\\\/Screen-Shot-2023-05-25-at-12.36.41-PM.png\",\"contentUrl\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/05\\\/Screen-Shot-2023-05-25-at-12.36.41-PM.png\",\"width\":932,\"height\":486,\"caption\":\"conditional rendering in react\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/conditional-rendering-in-react\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"react js\",\"item\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/react-js\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Conditional Rendering in React\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/\",\"name\":\"\",\"description\":\"Sustainable solutions\",\"publisher\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#organization\",\"name\":\"Codeflare Limited\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/codeflare.png\",\"contentUrl\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/codeflare.png\",\"width\":1040,\"height\":263,\"caption\":\"Codeflare Limited\"},\"image\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#\\\/schema\\\/person\\\/7e65653d49add95629f8c1053c5cd76a\",\"name\":\"codeflare\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g\",\"caption\":\"codeflare\"},\"description\":\"Latest tech news and coding tips.\",\"sameAs\":[\"https:\\\/\\\/codeflarelimited.com\\\/blog\",\"https:\\\/\\\/facebook.com\\\/codeflretech\",\"https:\\\/\\\/instagram.com\\\/codeflaretech\",\"https:\\\/\\\/x.com\\\/codeflaretech\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCuBLtiYqsajHdqw0uyt7Ofw?sub_confirmation=1\"],\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/author\\\/watcher\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Conditional Rendering in React","description":"Conditional rendering is a crucial concept in React, a popular JavaScript library for building user interfaces","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:\/\/codeflarelimited.com\/blog\/conditional-rendering-in-react\/","og_locale":"en_US","og_type":"article","og_title":"Conditional Rendering in React","og_description":"Conditional rendering is a crucial concept in React, a popular JavaScript library for building user interfaces","og_url":"https:\/\/codeflarelimited.com\/blog\/conditional-rendering-in-react\/","article_author":"https:\/\/facebook.com\/codeflretech","article_published_time":"2023-05-25T11:37:30+00:00","article_modified_time":"2023-05-25T11:37:31+00:00","og_image":[{"width":932,"height":486,"url":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/05\/Screen-Shot-2023-05-25-at-12.36.41-PM.png","type":"image\/png"}],"author":"codeflare","twitter_card":"summary_large_image","twitter_creator":"@codeflaretech","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"TechArticle","@id":"https:\/\/codeflarelimited.com\/blog\/conditional-rendering-in-react\/#article","isPartOf":{"@id":"https:\/\/codeflarelimited.com\/blog\/conditional-rendering-in-react\/"},"author":{"name":"codeflare","@id":"https:\/\/codeflarelimited.com\/blog\/#\/schema\/person\/7e65653d49add95629f8c1053c5cd76a"},"headline":"Conditional Rendering in React","datePublished":"2023-05-25T11:37:30+00:00","dateModified":"2023-05-25T11:37:31+00:00","mainEntityOfPage":{"@id":"https:\/\/codeflarelimited.com\/blog\/conditional-rendering-in-react\/"},"wordCount":759,"commentCount":0,"publisher":{"@id":"https:\/\/codeflarelimited.com\/blog\/#organization"},"image":{"@id":"https:\/\/codeflarelimited.com\/blog\/conditional-rendering-in-react\/#primaryimage"},"thumbnailUrl":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/05\/Screen-Shot-2023-05-25-at-12.36.41-PM.png","articleSection":["react js","softare development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/codeflarelimited.com\/blog\/conditional-rendering-in-react\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/codeflarelimited.com\/blog\/conditional-rendering-in-react\/","url":"https:\/\/codeflarelimited.com\/blog\/conditional-rendering-in-react\/","name":"Conditional Rendering in React","isPartOf":{"@id":"https:\/\/codeflarelimited.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/codeflarelimited.com\/blog\/conditional-rendering-in-react\/#primaryimage"},"image":{"@id":"https:\/\/codeflarelimited.com\/blog\/conditional-rendering-in-react\/#primaryimage"},"thumbnailUrl":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/05\/Screen-Shot-2023-05-25-at-12.36.41-PM.png","datePublished":"2023-05-25T11:37:30+00:00","dateModified":"2023-05-25T11:37:31+00:00","description":"Conditional rendering is a crucial concept in React, a popular JavaScript library for building user interfaces","breadcrumb":{"@id":"https:\/\/codeflarelimited.com\/blog\/conditional-rendering-in-react\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/codeflarelimited.com\/blog\/conditional-rendering-in-react\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codeflarelimited.com\/blog\/conditional-rendering-in-react\/#primaryimage","url":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/05\/Screen-Shot-2023-05-25-at-12.36.41-PM.png","contentUrl":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/05\/Screen-Shot-2023-05-25-at-12.36.41-PM.png","width":932,"height":486,"caption":"conditional rendering in react"},{"@type":"BreadcrumbList","@id":"https:\/\/codeflarelimited.com\/blog\/conditional-rendering-in-react\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/codeflarelimited.com\/blog\/"},{"@type":"ListItem","position":2,"name":"react js","item":"https:\/\/codeflarelimited.com\/blog\/react-js\/"},{"@type":"ListItem","position":3,"name":"Conditional Rendering in React"}]},{"@type":"WebSite","@id":"https:\/\/codeflarelimited.com\/blog\/#website","url":"https:\/\/codeflarelimited.com\/blog\/","name":"","description":"Sustainable solutions","publisher":{"@id":"https:\/\/codeflarelimited.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/codeflarelimited.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/codeflarelimited.com\/blog\/#organization","name":"Codeflare Limited","url":"https:\/\/codeflarelimited.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codeflarelimited.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2020\/11\/codeflare.png","contentUrl":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2020\/11\/codeflare.png","width":1040,"height":263,"caption":"Codeflare Limited"},"image":{"@id":"https:\/\/codeflarelimited.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/codeflarelimited.com\/blog\/#\/schema\/person\/7e65653d49add95629f8c1053c5cd76a","name":"codeflare","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g","caption":"codeflare"},"description":"Latest tech news and coding tips.","sameAs":["https:\/\/codeflarelimited.com\/blog","https:\/\/facebook.com\/codeflretech","https:\/\/instagram.com\/codeflaretech","https:\/\/x.com\/codeflaretech","https:\/\/www.youtube.com\/channel\/UCuBLtiYqsajHdqw0uyt7Ofw?sub_confirmation=1"],"url":"https:\/\/codeflarelimited.com\/blog\/author\/watcher\/"}]}},"jetpack_featured_media_url":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/05\/Screen-Shot-2023-05-25-at-12.36.41-PM.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/posts\/1365","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/comments?post=1365"}],"version-history":[{"count":1,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/posts\/1365\/revisions"}],"predecessor-version":[{"id":1367,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/posts\/1365\/revisions\/1367"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/media\/1366"}],"wp:attachment":[{"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/media?parent=1365"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/categories?post=1365"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/tags?post=1365"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}