How to use the storeon/preact function in storeon

To help you get started, we’ve selected a few storeon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kidqueb / preact-polka-ssr / src / client / pages / Foods.js View on Github external
const Foods = ({ title }) => {
  const [clicks, setClicks] = useState(0)
  const { dispatch, foods = [] } = useStoreon('foods')

  return (
    <div>
      <h1>{ title }</h1>
      
      <div>
        {foods.list.map(food =&gt; <p>{food}</p>)}
      </div>

      <p>{clicks}</p>
      <p>
        <button> setClicks(clicks + 1)}&gt;Add</button>
      </p>
    </div>
  )
}

storeon

Tiny (180 bytes) event-based Redux-like state manager for React and Preact

MIT
Latest version published 3 years ago

Package Health Score

58 / 100
Full package analysis