proxserve-react
v1.1.0
Published
React bindings for Proxserve as a state management tool
Downloads
7
Maintainers
Readme
proxserve-react
React bindings for Proxserve as a state manager
Install
npm install --save proxserve-react
Usage
// my-store.ts
import PRSM from 'proxserve-react';
const myStore = new PRSM<StoreType>('store-name');
// optional - initialize once
myStore.init({ myText: 'example', myNumber: 5 });
export { myStore };
import React from 'react'
import { myStore } from './my-store.ts'
function MyComponent() {
// use my store and listen (re-render) on myNumber changes
const my = myStore.useGet((obj) => [obj.myNumber]);
return <p>{my.myText} {my.myNumber}</p>
}
export function App() {
// optional - initialize on component render
useEffect(() => {
myStore.init(...);
}, []);
return <div><MyComponent /></div>
}
License
proxserve-react is APACHE-2.0 licensed.