4.0.0 • Published 2 months ago

@poly-state/react v4.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

React bindings for Poly state

How to install

npm install @poly-state/react
#or
yarn add @poly-state/react

Example

import { createStore } from '@poly-state/core';
import { createStoreSelector } from '@poly-state/react';

export type CounterStoreType = {
	count: number;
};

export const counterStoreInitialState: CounterStoreType = {
	count: 0,
};

export const counterStore = createStore(counterStoreInitialState);
export const useCounterStoreSelector = createStoreSelector(counterStore);

On Component level

const TestComponent = () => {
	const count = useCounterStoreSelector((state) => state.count);

	const increment = () => {
		counterStore.setCount((prev) => prev + 1);
	};

	return <h1 onClick={increment}>{count}</h1>;
};
4.0.0

2 months ago

3.0.0

2 years ago

1.2.4

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

1.1.5

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.1.3

2 years ago

1.2.1

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago