I always wanted a react component where I could set the state and it would survive hot-code-push, during development and during production, but it always seemed like a ton of work to make it happen.

React hooks changed all that - now it’s kind of easy! I just released a package which creates a tool to allow just this. I called it npdev:meteor-react-state. Check it out on atmosphere or git.

It let’s you do this:

import { useMeteorState } from 'npdev:meteor-react-state'

// setting a name is required by ReactiveDict for persistance
const [value, setValue] = useMeteorState('test', 'default value')

// this value will survive HCP!
setValue('another value')

Pretty spiffy!