Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/proyecto26/use-dictionary
A React useReducer() hook to use dictionaries (keys and values) 🔑
https://github.com/proyecto26/use-dictionary
dictionary hook hooks key-value react react-hook react-hooks react-library react-native react-reducer react-usereducer reactjs reducer types use-reducer usereducer usereducer-hooks
Last synced: 9 days ago
JSON representation
A React useReducer() hook to use dictionaries (keys and values) 🔑
- Host: GitHub
- URL: https://github.com/proyecto26/use-dictionary
- Owner: proyecto26
- License: mit
- Created: 2020-07-30T05:42:23.000Z (over 4 years ago)
- Default Branch: develop
- Last Pushed: 2024-10-27T16:19:04.000Z (21 days ago)
- Last Synced: 2024-10-29T22:37:28.335Z (18 days ago)
- Topics: dictionary, hook, hooks, key-value, react, react-hook, react-hooks, react-library, react-native, react-reducer, react-usereducer, reactjs, reducer, types, use-reducer, usereducer, usereducer-hooks
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/use-dictionary
- Size: 403 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# useDictionary
A React useReducer() hook to use dictionaries (keys and values) 🔑## Getting started
```tsx
const App: React.FC = () => {const initialState = {
id: '',
name: '',
password: '',
termsAndConditions: false,
};
const {
state,
onUpdateValue, // Update a value from the dictionary
onClearValue // Remove a value from the dictionary
onClear // Remove all values from the dictionary
} = useDictionary(initialState);const onSubmit = useCallback((event: React.FormEvent) => {
event.preventDefault();
console.log('Create User!', state);
}, [state]);
return (
Document:
onUpdateValue('id', e.target?.value)}
/>
Name:
onUpdateValue('name', e.target?.value)}
/>
Password:
onUpdateValue('password', e.target?.value)}
/>
Accept terms and conditions:
onUpdateValue('termsAndConditions', e.target?.checked)}
/>
);
}
```## Contributing ✨
When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated** ❤️.
You can learn more about how you can contribute to this project in the [contribution guide](https://github.com/proyecto26/use-dictionary/blob/develop/CONTRIBUTING.md).## Supporting 🍻
I believe in Unicorns 🦄
Support [me](http://www.paypal.me/jdnichollsc/2), if you do too.Donate **Ethereum**, **ADA**, **BNB**, **SHIBA**, **USDT/USDC**, **DOGE**, etc:
> Wallet address: jdnichollsc.eth
Please let us know your contributions! 🙏
## License ⚖️
This repository is available under the [MIT License](https://github.com/proyecto26/use-dictionary/blob/develop/LICENSE).## Happy coding 💯
Made with ❤️