@freakycoder/react-use-state-with-callback
Version:
Make the useState hook with a callback for React and React Native
55 lines (33 loc) • 2.06 kB
Markdown
<img alt="React Use State with Callback" src="assets/logo.png" width="1050"/>
[](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<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](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.