Giter VIP home page Giter VIP logo

atlj / react-native-reuix Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 424 KB

A redux-like store system for React Native Reanimated 2 shared values

Home Page: https://www.npmjs.com/package/react-native-reuix

License: MIT License

Shell 0.83% JavaScript 8.72% Java 35.94% TypeScript 30.95% Swift 0.32% Ruby 4.67% C 0.58% Objective-C 18.00%
npm-package react react-native reanimated2 redux redux-toolkit typescript

react-native-reuix's Introduction

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

react-native-reuix's People

Contributors

atlj avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.