Answers for "Example React Hook"

0

Example React Hook

const useCounter = (initialState = 0) => {
      const [count, setCount] = useState(initialState);
      const add = () => setCount(count + 1);
      const subtract = () => setCount(count - 1);
      return { count, add, subtract };
};
Posted by: Guest on April-14-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language