Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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) 🔑

Awesome Lists containing this project

README

        



MIT license


Current npm package version


Maintenance





Downloads


Total downloads


Follow @jdnichollsc

# 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 ❤️