useState how to access state after setting state code example
Example 1: update state in useState hook
// declare state using useState hook.
// someState is set to someInitialState
const [someState, setSomeState] = useState(someInitialState);
// setSomeState updates the current state
setSomeState(someOtherState);
Example 2: reading state react
class Example extends React.Component {
constructor(props) {
super(props);
this.state = {
count: 0
};
}