{"id":6664,"date":"2020-12-26T18:08:48","date_gmt":"2020-12-26T18:08:48","guid":{"rendered":"http:\/\/ismiletechnologies.com\/?p=6664"},"modified":"2022-12-09T01:15:44","modified_gmt":"2022-12-08T19:45:44","slug":"react-hooks","status":"publish","type":"post","link":"https:\/\/ismiletechnologies.com\/en_us\/dataops\/react-hooks\/","title":{"rendered":"React Hooks"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"6664\" class=\"elementor elementor-6664\" data-elementor-post-type=\"post\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-db92132 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"db92132\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-cf33420\" data-id=\"cf33420\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-42b4703 elementor-widget elementor-widget-spacer\" data-id=\"42b4703\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"spacer.default\">\n\t\t\t\t\t\t\t<div class=\"elementor-spacer\">\n\t\t\t<div class=\"elementor-spacer-inner\"><\/div>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-279b752 elementor-widget elementor-widget-text-editor\" data-id=\"279b752\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<h4><span style=\"text-decoration: underline;\"><b>What is HR Automation?<\/b><\/span><\/h4>\nIt is a feature introduced to play with states in functional components as previously it was just being used with class components only.\n\nHooks are the functions which &#8220;hook into&#8221; React state and life cycle features from function components.\n\nRULES FOR USING HOOKS:\n\n(1)- Only call hooks at top level\n\n(2)- Only call hooks from react function\n\nSYNTAX INVOLVED WITH USING STATE IN HOOKS:\n\n\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-8218afb elementor-widget elementor-widget-text-editor\" data-id=\"8218afb\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>\u00a0<\/p><p>import React, {useState} from &#8216;React;<\/p><ol><li><strong>import<\/strong>React,\u00a0{\u00a0useState\u00a0}\u00a0from\u00a0&#8216;react&#8217;;\u00a0\u00a0<\/li><li>\u00a0<\/li><li>function\u00a0CountApp()\u00a0{\u00a0\u00a0<\/li><li>\/\/\u00a0Declare\u00a0a\u00a0new\u00a0state\u00a0variable,\u00a0which\u00a0we&#8217;ll\u00a0call\u00a0&#8220;count&#8221;\u00a0\u00a0<\/li><li><strong>const<\/strong>\u00a0[count,\u00a0setCount]\u00a0=\u00a0useState(0);\u00a0\u00a0<\/li><li>\u00a0<\/li><li><strong>return<\/strong>\u00a0(\u00a0\u00a0<\/li><li>&lt;div&gt;\u00a0\u00a0<\/li><li>&lt;p&gt;You\u00a0clicked\u00a0{count}\u00a0times&lt;\/p&gt;\u00a0\u00a0<\/li><li>&lt;button\u00a0onClick={()\u00a0=&gt;\u00a0setCount(count\u00a0+\u00a01)}&gt;\u00a0\u00a0<\/li><li>Click\u00a0me\u00a0\u00a0<\/li><li>&lt;\/button&gt;\u00a0\u00a0<\/li><li>&lt;\/div&gt;\u00a0\u00a0<\/li><li>);\u00a0\u00a0<\/li><li>}\u00a0\u00a0<\/li><li>export\u00a0<strong>default<\/strong>CountApp;<\/li><\/ol>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-2763475 elementor-widget elementor-widget-text-editor\" data-id=\"2763475\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>BASIC HOOKS:<\/p><p>(1)- useState()<\/p><p>(2)- useEffect()<\/p><p>(3)- useContext()<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-6ee04a7 elementor-widget elementor-widget-spacer\" data-id=\"6ee04a7\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"spacer.default\">\n\t\t\t\t\t\t\t<div class=\"elementor-spacer\">\n\t\t\t<div class=\"elementor-spacer-inner\"><\/div>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-16e398e elementor-author-box--align-left elementor-widget elementor-widget-author-box\" data-id=\"16e398e\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"author-box.default\">\n\t\t\t\t\t\t\t<div class=\"elementor-author-box\">\n\t\t\t\n\t\t\t<div class=\"elementor-author-box__text\">\n\t\t\t\t\t\t\t\t\t<div >\n\t\t\t\t\t\t<h4 class=\"elementor-author-box__name\">\n\t\t\t\t\t\t\tSana Eram\t\t\t\t\t\t<\/h4>\n\t\t\t\t\t<\/div>\n\t\t\t\t\n\t\t\t\t\t\t\t\t\t<div class=\"elementor-author-box__bio\">\n\t\t\t\t\t\t<p>Data Scientist Intern<\/p>\n\t\t\t\t\t<\/div>\n\t\t\t\t\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>What is HR Automation? It is a feature introduced to play with states in functional components as previously it was just being used with class components only. Hooks are the functions which &#8220;hook into&#8221; React state and life cycle features from function components. RULES FOR USING HOOKS: (1)- Only call hooks at top level (2)- [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[249],"tags":[],"class_list":["post-6664","post","type-post","status-publish","format-standard","hentry","category-dataops"],"_links":{"self":[{"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/posts\/6664","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/comments?post=6664"}],"version-history":[{"count":1,"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/posts\/6664\/revisions"}],"predecessor-version":[{"id":36093,"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/posts\/6664\/revisions\/36093"}],"wp:attachment":[{"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/media?parent=6664"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/categories?post=6664"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/tags?post=6664"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}