How to use the react-context-hook.useStore function in react-context-hook

To help you get started, we’ve selected a few react-context-hook 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 Spyna / react-context-hook / example / src / SetString.js View on Github external
export default function() {
  const [username, setUsername] = useStore('username', 'spyna', true)
  const [textValue, setTextValue] = React.useState(username)
  function onChange(event) {
    setTextValue(event.target.value)
  }

  function onSubmit(event) {
    event.preventDefault()
    setUsername(textValue)
  }

  return (
    <section>
      <h3>
        Set the value <em>"username"</em> in the store
      </h3>
      <form></form></section>
github Spyna / react-context-hook / example / src / SetAmount.js View on Github external
export default function() {
  const [count, setCount, deleteCount] = useStore('count', 0)
  return (
    <section>
      <h3>
        Set the value <em>"count"</em> in the store
      </h3>
      <button> setCount(count - 1)}&gt;Decrement - </button>
      <span>{count}</span>
      <button> setCount(count + 1)}&gt;Increment + </button>
      <button> deleteCount()}&gt;Delete "count" from store</button>
    </section>
  )
}

react-context-hook

A React.js global state manager with Hooks and Context API

MIT
Latest version published 3 years ago

Package Health Score

48 / 100
Full package analysis