0.0.1 • Published 3 years ago

var-redux v0.0.1

Weekly downloads
2
License
ISC
Repository
github
Last release
3 years ago

var-redux

import { createStore, Provide, useConnect } from 'var-redux';

const store = createStore({
  theme: {
    foreground: '#000000',
    background: '#eeeeee',
  },
});

function App() {
  return (
    <Provide store={store}>
      <Toolbar />
    </Provide>
  );
}

function Toolbar() {
  const { state, dispatch } = useConnect();
  const { theme } = state;
  React.useEffect(() => {
    setTimeout(() => {
      dispatch('theme', {
        foreground: 'green',
        background: 'red',
      });
    }, 500);
  }, []);
  return (
    <button style={{ background: theme.background, color: theme.foreground }}>
      I am styled by theme context!
    </button>
  );
}

export default App;