React Hook

Piyal Das
3 min readNov 5, 2020
  1. When we use hooks no need to use class based components. How we can use hook, hook only call at the top level. only call hooks from react function. two types of hooks a) basic hooks b) additional hooks. basic hooks are : * useState * useEffect * useContext. additional hooks are: * useReducer * useCallback * usememo * useRef * useImperativeHandle * useLayoutEffect * useDebugValue. their are mainly usually use basic hooks. lets discuss about basic hooks.
  2. useState:

where you can use straight state. useState called contains state. when you implement useState the first argument you give it initial value. And it returns an array. also we found a function for second argument . always first index is called value, second index is update value.

Photo by Ferenc Almasi on Unsplash

3. useEffect :

we usually called it a magic box. the reason of called magic box is, only one time implementation, then we use it several time. useEffect also called a another option of lifecycle method. whatever lifecycle did , useEffect do it in a better way. To call after update a function implement useEffect. this is calling when there is any state change or you can control it .

useEffect implementation.

3. useContext:

useContext cleaning our code and remove the render props concept ,it implement simply called a function and nicely work.

another one is useReducer.its kind of a alternative of redux. context + hooks = goodbye Redux(ha ha)

4. find the largest element of an array:

Take a array and their have some element. we want to find out the largest element of this array .its so easy. firstly take your array first index .then we implement a for loop. all the step write down the pic.

5. Truthy vs falsy value:

if we implement a condition and its value are matching the condition then its called truthy values another one is falsy values. if any value is number all are true except 0 (false) . every string value is truthy except empty string . every undefined thing is falsy value. if you set null value its also false and also NaN.

6. null vs undefined:

When you declare a variable through var and do not give it a value , it will have the value undefined . another one is null, null means not existed .if you search a thing which is not existed in your value then its feedback is null.

7.Double equal vs triple equal:

if you use double equal it can not be check stricly and another side if you use triple equal it can be check strickly. the important thing is double equal is check only value and triple equal is check value plus type.thats why we use triple equal.

--

--

Piyal Das
0 Followers

Hello i am Piyal. I am a frontend web developer. I like to keep it professional. My career is developing website, but my life is adventuring.