react-use-state-with-callback

Make the useState hook with a callback for React and React Native

Stars
5

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.

Badges
Extracted from project README
Battle Tested React Use State with Callback npm version npm License: MIT styled with prettier
Related Projects