{"id":99284,"date":"2019-10-30T07:00:36","date_gmt":"2019-10-30T05:00:36","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=99284"},"modified":"2019-10-29T10:58:19","modified_gmt":"2019-10-29T08:58:19","slug":"reactjs-setstate-example","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/reactjs-setstate-example.html","title":{"rendered":"ReactJS setState Example"},"content":{"rendered":"<p>ReactJS has grown in popularity and is one of the most used frameworks. In this article, we look at the setState method of ReactJS. With earlier versions of React state feature was limited to components implemented using ES6 classes. But now with the introduction of hooks even function components can have state. We look at both the cases and how we should modify state by using the setState function and its different variants.<\/p>\n<p>For the purpose of this article I will create a simple React application using the create-react-app package from the ReactJS team. The tools and frameworks used to implement this example are as follows. Some are mandatory whilst others may be replaced with your favorites.<\/p>\n<ul class=\"wp-block-list\">\n<li><a aria-label=\"create-react-app (opens in a new tab)\" href=\"https:\/\/www.npmjs.com\/package\/create-react-app\" target=\"_blank\" rel=\"noreferrer noopener\">create-react-app<\/a><\/li>\n<li><a aria-label=\"ReactJS (opens in a new tab)\" href=\"https:\/\/reactjs.org\" target=\"_blank\" rel=\"noreferrer noopener\">ReactJS<\/a><\/li>\n<li><a aria-label=\"Visual Studio Code IDE (opens in a new tab)\" href=\"https:\/\/code.visualstudio.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Visual Studio Code IDE<\/a><\/li>\n<\/ul>\n<h2 class=\"wp-block-heading\">1. Initial Setup<\/h2>\n<p>We get started by running the below command. This creates the initial structure and configuration of our example application.<\/p>\n<pre class=\"brush: bash;\">&gt;npx create-react-app my-app .\n<\/pre>\n<p>Once this command completes our application must be ready. The folder structure should resemble the below screen shot:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"249\" height=\"465\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/10\/FolderStructureSetStateEx.jpg\" alt=\"ReactJS setState - Application Structure\" class=\"wp-image-99579\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/10\/FolderStructureSetStateEx.jpg 249w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/10\/FolderStructureSetStateEx-161x300.jpg 161w\" sizes=\"(max-width: 249px) 100vw, 249px\" \/><figcaption>Application Structure<\/figcaption><\/figure>\n<\/div>\n<h2 class=\"wp-block-heading\">2. State in Class Component<\/h2>\n<p>Let us create our first component named ClickCounter in a file named the same. We use the ES6 class construct to build our component. This component renders a couple of buttons and a span. On click of one of the buttons a counter is updated and the count is displayed in the span. On click of the other button we reset the counter back to zero.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>The code for our component looks like below. We store the counter in state which is internal to the component. On click we update the state using the version of setState that takes a callback and passes it the previous state and props as parameters.<\/p>\n<p><span style=\"text-decoration: underline\"><em>ClickCounter.js<\/em><\/span><\/p>\n<pre class=\"brush: js;\">import React from 'react';\n\nclass ClickCounter extends React.Component {\n    constructor(props) {\n        super(props);\n        this.state = { count: 0 };\n    }\n    render() {\n        return &lt;&gt;\n            &lt;span&gt;Button clicked {this.state.count} times!\n                &lt;\/span&gt;\n            &lt;button onClick={this.handleClick}&gt;Click Me&lt;\/button&gt;\n            &lt;button onClick={this.resetCounter}&gt;\n                 Reset Counter&lt;\/button&gt;\n        &lt;\/&gt;;\n    }\n    resetCounter = () =&gt; {\n        this.setState({ count: 0 });\n    }\n    handleClick = () =&gt; {\n        this.setState((state, props) =&gt; \n            ({ count: state.count + 1 }));\n    }\n}\nexport default ClickCounter;\n<\/pre>\n<p>As you can see we have used the callback version of setState in the handleClick event handler. We use the value of the counter in the previous state to create a new state. This leads to an update of our component and it is re rendered. Similarly in the reset button&#8217;s click handler we use the version of setState to reset the counter back to zero. Next let us implement the same using function components and hooks.<\/p>\n<h2 class=\"wp-block-heading\">3. State in Function Components<\/h2>\n<p>Now let us implement the component we wrote above as function component. We create a separate file named ClickComponentFunc.js for this component. To enable using state with this component we additionally import the useState hook from react. We use it as follows to create a property count in state:<\/p>\n<pre class=\"brush: js;\">const [count, setCount] = useState(0);\n<\/pre>\n<p>And that&#8217;s how we can use state in a function component. The count variable can be used to access the state property and setCount can be used to set the value of the count property. The complete code for our function component looks like below<\/p>\n<p><span style=\"text-decoration: underline\"><em>ClickComponentFunc.js<\/em><\/span><\/p>\n<pre class=\"brush: js;\">import React, { useState } from \"react\";\n\nexport default function ClickCounterFunc(props) {\n\n    const [count, setCounter] = useState(0);\n    const updateCounter = () =&gt; {\n        setCounter(count + 1);\n    };\n    const resetCounter = () =&gt; {\n        setCounter(0);\n    };\n    return &lt;&gt;\n        &lt;span&gt;Button clicked {count} times!&lt;\/span&gt;\n        &lt;button onClick={updateCounter}&gt;Click Me!&lt;\/button&gt;\n        &lt;button onClick={resetCounter}&gt;Reset Counter&lt;\/button&gt;\n    &lt;\/&gt;;\n\n}\n<\/pre>\n<p>In the next section we run our application and see the results.<\/p>\n<h2 class=\"wp-block-heading\">4. Running the Application<\/h2>\n<p>To run the application and see the results we run the following command at the root of our application<\/p>\n<pre class=\"brush: bash;\">&gt;npm start\n<\/pre>\n<p>This command starts our application and opens it in the default browser at the url http:\/\/localhost:3000. The result looks like below<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"782\" height=\"479\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/10\/ProjectOutputsetStateEx-2.jpg\" alt=\"\" class=\"wp-image-99588\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/10\/ProjectOutputsetStateEx-2.jpg 782w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/10\/ProjectOutputsetStateEx-2-300x184.jpg 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/10\/ProjectOutputsetStateEx-2-768x470.jpg 768w\" sizes=\"(max-width: 782px) 100vw, 782px\" \/><figcaption>Project Output<\/figcaption><\/figure>\n<\/div>\n<h2 class=\"wp-block-heading\">5. Download the Source Code<\/h2>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/10\/JCG-ReactJS-setState-Example.zip\"><strong>ReactJS setState Example<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>ReactJS has grown in popularity and is one of the most used frameworks. In this article, we look at the setState method of ReactJS. With earlier versions of React state feature was limited to components implemented using ES6 classes. But now with the introduction of hooks even function components can have state. We look at &hellip;<\/p>\n","protected":false},"author":82952,"featured_media":92051,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1903],"tags":[1919],"class_list":["post-99284","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-react-js","tag-reactjs"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>ReactJS setState Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Interested to learn more about ReactJS? Then check out our detailed example on ReactJS setState!ReactJS is one of the most used frameworks.\" \/>\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.javacodegeeks.com\/reactjs-setstate-example.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"ReactJS setState Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Interested to learn more about ReactJS? Then check out our detailed example on ReactJS setState!ReactJS is one of the most used frameworks.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/reactjs-setstate-example.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2019-10-30T05:00:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/react-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Siddharth Seth\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Siddharth Seth\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/reactjs-setstate-example.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/reactjs-setstate-example.html\"},\"author\":{\"name\":\"Siddharth Seth\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/09c54717e2cc7956aa8a2df61330f18c\"},\"headline\":\"ReactJS setState Example\",\"datePublished\":\"2019-10-30T05:00:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/reactjs-setstate-example.html\"},\"wordCount\":541,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/reactjs-setstate-example.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2019\\\/05\\\/react-logo.jpg\",\"keywords\":[\"Reactjs\"],\"articleSection\":[\"React.js\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/reactjs-setstate-example.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/reactjs-setstate-example.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/reactjs-setstate-example.html\",\"name\":\"ReactJS setState Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/reactjs-setstate-example.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/reactjs-setstate-example.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2019\\\/05\\\/react-logo.jpg\",\"datePublished\":\"2019-10-30T05:00:36+00:00\",\"description\":\"Interested to learn more about ReactJS? Then check out our detailed example on ReactJS setState!ReactJS is one of the most used frameworks.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/reactjs-setstate-example.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/reactjs-setstate-example.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/reactjs-setstate-example.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2019\\\/05\\\/react-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2019\\\/05\\\/react-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/reactjs-setstate-example.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Web Development\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/web-development\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"JavaScript\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/web-development\\\/javascript\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"React.js\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/web-development\\\/javascript\\\/react-js\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"ReactJS setState Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/09c54717e2cc7956aa8a2df61330f18c\",\"name\":\"Siddharth Seth\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/86a5133a5e9d79f7997e2649b1afe58e895c0d88df47b3359103ec4c1a2077d6?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/86a5133a5e9d79f7997e2649b1afe58e895c0d88df47b3359103ec4c1a2077d6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/86a5133a5e9d79f7997e2649b1afe58e895c0d88df47b3359103ec4c1a2077d6?s=96&d=mm&r=g\",\"caption\":\"Siddharth Seth\"},\"description\":\"Siddharth is a Software Development Professional with a Master degree in Computer Applications from IGNOU. He has over 14 years of experience. And currently focused on Software Architecture, Cloud Computing, JavaScript Frameworks for Client and Server, Business Intelligence.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/siddharth-seth-240180\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/siddharth_seth1980\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"ReactJS setState Example - Java Code Geeks","description":"Interested to learn more about ReactJS? Then check out our detailed example on ReactJS setState!ReactJS is one of the most used frameworks.","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.javacodegeeks.com\/reactjs-setstate-example.html","og_locale":"en_US","og_type":"article","og_title":"ReactJS setState Example - Java Code Geeks","og_description":"Interested to learn more about ReactJS? Then check out our detailed example on ReactJS setState!ReactJS is one of the most used frameworks.","og_url":"https:\/\/www.javacodegeeks.com\/reactjs-setstate-example.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2019-10-30T05:00:36+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/react-logo.jpg","type":"image\/jpeg"}],"author":"Siddharth Seth","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Siddharth Seth","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/reactjs-setstate-example.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/reactjs-setstate-example.html"},"author":{"name":"Siddharth Seth","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/09c54717e2cc7956aa8a2df61330f18c"},"headline":"ReactJS setState Example","datePublished":"2019-10-30T05:00:36+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/reactjs-setstate-example.html"},"wordCount":541,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/reactjs-setstate-example.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/react-logo.jpg","keywords":["Reactjs"],"articleSection":["React.js"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/reactjs-setstate-example.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/reactjs-setstate-example.html","url":"https:\/\/www.javacodegeeks.com\/reactjs-setstate-example.html","name":"ReactJS setState Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/reactjs-setstate-example.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/reactjs-setstate-example.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/react-logo.jpg","datePublished":"2019-10-30T05:00:36+00:00","description":"Interested to learn more about ReactJS? Then check out our detailed example on ReactJS setState!ReactJS is one of the most used frameworks.","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/reactjs-setstate-example.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/reactjs-setstate-example.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/reactjs-setstate-example.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/react-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/05\/react-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/reactjs-setstate-example.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Web Development","item":"https:\/\/www.javacodegeeks.com\/category\/web-development"},{"@type":"ListItem","position":3,"name":"JavaScript","item":"https:\/\/www.javacodegeeks.com\/category\/web-development\/javascript"},{"@type":"ListItem","position":4,"name":"React.js","item":"https:\/\/www.javacodegeeks.com\/category\/web-development\/javascript\/react-js"},{"@type":"ListItem","position":5,"name":"ReactJS setState Example"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/09c54717e2cc7956aa8a2df61330f18c","name":"Siddharth Seth","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/86a5133a5e9d79f7997e2649b1afe58e895c0d88df47b3359103ec4c1a2077d6?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/86a5133a5e9d79f7997e2649b1afe58e895c0d88df47b3359103ec4c1a2077d6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/86a5133a5e9d79f7997e2649b1afe58e895c0d88df47b3359103ec4c1a2077d6?s=96&d=mm&r=g","caption":"Siddharth Seth"},"description":"Siddharth is a Software Development Professional with a Master degree in Computer Applications from IGNOU. He has over 14 years of experience. And currently focused on Software Architecture, Cloud Computing, JavaScript Frameworks for Client and Server, Business Intelligence.","sameAs":["https:\/\/www.linkedin.com\/in\/siddharth-seth-240180\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/siddharth_seth1980"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/99284","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/82952"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=99284"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/99284\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/92051"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=99284"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=99284"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=99284"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}