Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
The simplest state manager for Expo and React Native
Use yarn
yarn add aniuta
or npm
npm i -S aniuta
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
❌ 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,
};
}
Message us at hello@4twiggers.com
FAQs
The simplest state manager for Expo and React Native
The npm package aniuta receives a total of 36 weekly downloads. As such, aniuta popularity was classified as not popular.
We found that aniuta demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.