react-native-reuix
A redux-like store system for React Native Reanimated 2 shared values
Prerequisites
This module needs
React Native Reanimated 2 to work, first make sure you have this package installed
Installation
Using Yarn
yarn add react-native-reuix
Using npm
npm install react-native-reuix
Usage
1. Create a Store
export const sharedValueStore = createSharedValueStore({
initialState: {
testOpacity: 0.5,
},
actions: {
setTestOpacity(state, payload: number) {
state.testOpacity = payload;
},
},
});
2. Wrap Your App With SharedValueStoreProvider and Pass Your Store
export default function App() {
return (
<SharedValueStoreProvider store={sharedValueStore}>
<TestView />
</SharedValueStoreProvider>
);
}
3. Read Values From Store
Get the store using useSharedValueStore hook
const sharedValueStore = useSharedValueStore<TestStoreType>();
Then you can freely read values from store
sharedValueStore.value.testOpacity
4. Dispatch Actions to Change Values
Get the dispatcher using useSharedValueDispatch hook
const sharedValueDispatch = useSharedValueDispatch<TestStoreType>();
Dispatch actions to change values
sharedValueDispatch('setTestOpacity', 1);
Rest
Rest of the docs are coming soon
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT