UNPKG

react-custom-hook

Version:

A Library, which holds a plenty of hooks, is useful for developers to minimize their code and make their lives easier

16 lines (11 loc) 367 B
import { useState } from "react"; const usePreviousCurrentState = (value = "") => { const [currentstate, setCurrentState] = useState(["", value]); const updateState = (value) => { setCurrentState((props) => { return [props[1], value]; }); }; return [currentstate[0], currentstate[1], updateState]; }; export default usePreviousCurrentState;