@freakycoder/react-use-state-with-callback
v0.1.2
Published
Make the useState hook with a callback for React and React Native
Downloads
7
Maintainers
Readme
Installation
Add the dependency:
npm i @freakycoder/react-use-state-with-callback
Peer Dependencies
Zero Dependency
Usage
Import
import useStateWithCallback from "@freakycoder/react-use-state-with-callback";
Fundamental Usage
const [isSelected, setIsSelected] = useStateWithCallback<boolean>(false);
// USAGE
setIsSelected(true, (newValue: boolean) => console.log(newValue)); // true
Credits
Big thanks to MJ Studio
from StackoverFlow. I just converted his awesome wrapper solution to a library.
MJ Studio's StackoverFlow Answer
Author
FreakyCoder, [email protected]
License
React Use State with Callback is available under the MIT license. See the LICENSE file for more info.