Read more about hooks
here
https://reactjs.org/docs/hooks-intro.html
here is a example of hooks where i tried to create three hooks
https://stackblitz.com/edit/react-1tprrk
a real simple hook
here
https://reactjs.org/docs/hooks-intro.html
here is a example of hooks where i tried to create three hooks
https://stackblitz.com/edit/react-1tprrk
a real simple hook
import React, { useState } from 'react';
//my counter class using useState
export const Counter=(props)=>{
//each function component can handle in own state
const [count,setCount]=useState(0);
return(
<div style={{background:props.color}}>Your click Button is:<button onClick={
()=>{
setCount(++count);
//return back a call to parent so i can listen the change
if(props.callBack)
{
props.callBack(count,props.name);
}
}
}>{props.name}</button><span>{count}</span></div>
)
}
Comments
Post a Comment