const useResetScore = () => { const [score, setScore] = useRecoilState(gameScore) return () => { setScore(0) } } ... const resetScore = useResetScore() ... <button onClick={resetScore}>Reset</button>
const useResetScore = () => { const [score, setScore] = useRecoilState(gameScore) return () => { setScore(0) } } ... const resetScore = useResetScore() ... <button onClick={resetScore}>Reset</button>