Skip to content

Instantly share code, notes, and snippets.

@y-nk
Last active December 19, 2019 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save y-nk/90a7277795a19fb9b5b46140dcb043c2 to your computer and use it in GitHub Desktop.
Save y-nk/90a7277795a19fb9b5b46140dcb043c2 to your computer and use it in GitHub Desktop.
import { useState } from 'react'
export default (prop, value = null, context = {}) => {
const [val, setVal] = useState(value)
Object.defineProperty(context, prop, {
get() { return val },
set(val) { setVal(val) },
})
return context
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment