import * as React from 'react' ; import { PureStore } from "./index" ; class PureStoreReact < S , T > extends PureStore < S , T > { usePureStore ( ) ; usePureStore < X > ( getter ? ) ; usePureStore ( getter ? ) { if ( getter ) { return new PureStoreReact ( this , getter ) . usePureStore ( ) ; } const [ _ , setState ] = React . useState ( this . getState ( ) ) ; React . useEffect ( ( ) => { return this . subscribe ( ( ) => setState ( this . getState ( ) ) ) ; } , [ ] ) ; return [ this . getState ( ) , this . update ] as const ; } } export default < S > ( state ) => ( new PureStoreReact ( null , ( s ) => s , state ) ) ; export { PureStoreReact as PureStore } ;