https://github.com/wrathchaos/react-use-state-with-callback
Make the useState hook with a callback for React and React Native
https://github.com/wrathchaos/react-use-state-with-callback
hook react react-hook react-native reactjs state state-management usestate
Last synced: 7 months ago
JSON representation
Make the useState hook with a callback for React and React Native
- Host: GitHub
- URL: https://github.com/wrathchaos/react-use-state-with-callback
- Owner: WrathChaos
- Created: 2021-10-09T16:39:21.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-22T17:05:18.000Z (over 2 years ago)
- Last Synced: 2025-02-26T18:24:02.448Z (7 months ago)
- Topics: hook, react, react-hook, react-native, reactjs, state, state-management, usestate
- Language: Java
- Homepage: https://freakycoder.com/
- Size: 648 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://github.com/WrathChaos/react-use-state-with-callback)
[](https://github.com/WrathChaos/react-use-state-with-callback)
[](https://www.npmjs.com/package/@freakycoder/react-use-state-with-callback)
[](https://www.npmjs.com/package/@freakycoder/react-use-state-with-callback)

[](https://opensource.org/licenses/MIT)
[](https://github.com/prettier/prettier)# Installation
Add the dependency:
```bash
npm i @freakycoder/react-use-state-with-callback
```## Peer Dependencies
**Zero Dependency**
# Usage
## Import
```ts
import useStateWithCallback from "@freakycoder/react-use-state-with-callback";
```## Fundamental Usage
```ts
const [isSelected, setIsSelected] = useStateWithCallback(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](https://stackoverflow.com/a/61725731/2247055)
## Author
FreakyCoder, kurayogun@gmail.com
## License
React Use State with Callback is available under the MIT license. See the LICENSE file for more info.