All Projects → 4TWIGGERS → aniuta

4TWIGGERS / aniuta

Licence: other
The simplest state manager for Expo and React Native

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to aniuta

Pillar Valley
👾A cross-platform video game built with Expo, three.js, and Firebase! 🎮🕹
Stars: ✭ 242 (+591.43%)
Mutual labels:  expo
4noobs-mobile
App mobile do 4Noobs
Stars: ✭ 69 (+97.14%)
Mutual labels:  expo
freecbt
✨🐙 A GPL Licensed Cognitive Behavioral Therapy app for iOS and Android
Stars: ✭ 49 (+40%)
Mutual labels:  expo
Rn Pdf Reader Js
📄 PDF reader in JavaScript only for Expo - Android & iOS capable
Stars: ✭ 254 (+625.71%)
Mutual labels:  expo
react-native-todo
Todo-List app using react-native SwipeView and redux.js with ES6 standards
Stars: ✭ 77 (+120%)
Mutual labels:  expo
expo-push-notification-helper
💬🔥This package helps you make expo push notification for React Native easy to use.
Stars: ✭ 32 (-8.57%)
Mutual labels:  expo
Use Expo
Complementary hooks for Expo
Stars: ✭ 233 (+565.71%)
Mutual labels:  expo
react-native-popable
Popovers, tooltips for React Native
Stars: ✭ 298 (+751.43%)
Mutual labels:  expo
expo-file-manager
A file manager app made with React Native & Expo
Stars: ✭ 110 (+214.29%)
Mutual labels:  expo
react-native-bottom-bar
Fully customizable BottomBar with unique design shape for React Native.
Stars: ✭ 74 (+111.43%)
Mutual labels:  expo
react-native-expo-examples
Learn React Native (Expo CLI) by examples.
Stars: ✭ 167 (+377.14%)
Mutual labels:  expo
tasit-apps
Native mobile Ethereum dapps for mainstream users
Stars: ✭ 35 (+0%)
Mutual labels:  expo
markets-react
📈 Check the stock market, from your phone!
Stars: ✭ 47 (+34.29%)
Mutual labels:  expo
Expo Pixi
Tools for using pixi.js in Expo
Stars: ✭ 253 (+622.86%)
Mutual labels:  expo
hackerweb-native-2
HackerWeb 2: A read-only Hacker News client.
Stars: ✭ 51 (+45.71%)
Mutual labels:  expo
Galio
Galio is a beautifully designed, Free and Open Source React Native Framework
Stars: ✭ 2,772 (+7820%)
Mutual labels:  expo
photos
"Fx Fotos" is an opensource gallery app in react native with the same smoothness and features of Google Photos and Apple Photos. It is backend gnostic and connects to decentralized backends like "box", "Dfinity", "Filecoin" and "Crust".
Stars: ✭ 620 (+1671.43%)
Mutual labels:  expo
react-native-web-expo-boilerplate
I am no longer in maintenance
Stars: ✭ 64 (+82.86%)
Mutual labels:  expo
dooboo-expo
Complete boilerplate for react-native app with expo. Contains typescript, router, test, localization, navigation, hook and etc.
Stars: ✭ 52 (+48.57%)
Mutual labels:  expo
react-native-qrimage-decoder
QR image decoder for React Native
Stars: ✭ 13 (-62.86%)
Mutual labels:  expo

This library will no longer be maintained. Please consider Zustand, Valtio, Recoil or Jotai instead

Aniuta

The simplest state manager for Expo and React Native

Aniuta logo

Installation

Use yarn

yarn add aniuta

or npm

npm i -S aniuta

Usage

import React, { useState } from 'react';
import { Provider, createStore } from 'aniuta';
import { View, Text, Button } from 'react-native';

//useCounter.js. key must be unique
const useCounter = createStore({
   key: 'CounterStore',
   Store: () => {
      const [count, setCount] = useState(0);

      const increment = () => setCount(count + 1);
      const decrement = () => setCount(count - 1);
      const reset = () => setCount(0);

      return { count, increment, decrement, reset };
   },
});

//counter.js - Counter Component
function Counter() {
   const { count, increment, decrement, reset } = useCounter();

   return (
      <View>
         <Button title='-' onPress={decrement} />
         <Text>{count.toString()}</Text>
         <Button title='+' onPress={increment} />
         <Button title='reset' onPress={reset} />
      </View>
   );
}

//Just wrap App with Provider component and you are good to go
export default function App() {
   return (
      <View>
         <Provider>
            <Counter />
         </Provider>
      </View>
   );
}

See more examples in ./example folder

Tips

Do not create single store for everything.

Create store as many stores as needed. Multiple stores will prevent unnessesary re-renders


Do not use store hook inside another store.

If you need to have a hook with 2 store data create additional hook. See below.

For sake of this example lets say we have 2 separate count stores. First for Odd numbers and second for Even numbers.

const useOdds = createStore({
   key: 'OddsStore',
   Store: () => {
      const [count, setCount] = useState(1);

      const increment = () => setCount(count + 2);
      const decrement = () => setCount(count - 2);

      return { count, increment, decrement };
   },
});

const useEvens = createStore({
   key: 'EvensStore',
   Store: () => {
      const [count, setCount] = useState(0);

      const increment = () => setCount(count + 2);
      const decrement = () => setCount(count - 2);

      return { count, increment, decrement };
   },
});

Create third wrapper hook which can be used inside component:

function useOddsAndEvens() {
   const odds = useOdds();
   const evens = useEvens();

   return {
      odds,
      evens,
   };
}

App using Aniuta so far

Based On

Related

Hire us

Message us at [email protected]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].