hyperapp-context
hyperapp-context copied to clipboard
Do we need that in 2.0?
Same as with hyperapp-nestable: I'm toying lightly with ideas for stateful components and context. If I figure something out I'll update this and nestable.
If what you need is a replacement to the "subview" feature of Hyperapp v1, which gave access to the global state in any component, without needing to pass props down, then have a look at this gist I made a year ago:
https://gist.github.com/zaceno/aef8cb759e44616536d52479b25ba60e
It worked fine then, and I think it still should but haven't tested recently.
Basic usage:
const {h, app} = hyperapp
const SubView = view(state => <h1>Hello {state.message}</h1>)
withViews(app)({
init: {message: 'World'},
view: state => <body><SubView /></body>,
node: document.body,
})