Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import {
syncBlock,
useRegisterIncrementDispatcher,
initialState,
reducer,
ids,
useCheckTearing,
shallowEqual,
} from '../common';
const counter = (store) => {
store.on('@init', () => initialState);
store.on('dispatch', reducer);
};
const store = createStore([counter]);
const Counter = React.memo(() => {
const { count } = useStoreon('count');
syncBlock();
return <div>{count}</div>;
}, shallowEqual);
const Main = () => {
const { count, dispatch } = useStoreon('count');
useCheckTearing();
useRegisterIncrementDispatcher(React.useCallback(() => {
dispatch('dispatch', { type: 'increment' });
}, [dispatch]));
const [localCount, localIncrement] = React.useReducer((c) => c + 1, 0);
const normalIncrement = () => {
dispatch('dispatch', { type: 'increment' });