1import { useStateCallback } from 'react-modern-hooks'23const Demo = () => {4 const [value, setValue] = useStateCallback<string>('')56 const handleChange = (e: any) => {7 setValue(e.target.value, (currentValue) => {8 // Perform search with the current set value in the state9 console.log('Text to perform search', currentValue)10 handleSearch(currentValue)11 })12 }1314 return (15 <div>16 <p>Perform an action with current value set in the state</p>17 <input18 placeholder='Type something...'19 value={value}20 onChange={handleChange}21 />22 </div>23 )24}2526export default Demo
initialState - The initial state value
state - The updated state value as first array item
setState - The function to handle change of the state value, Which also receives an optional callback using the current state