New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade to Preact X #2
Conversation
export const Provider = (props) => { | ||
const store = props.store | ||
const rest = {} | ||
Object.keys(props).forEach((key) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
microbundle doesn't like the spread operator. Just do it manually here.
} | ||
}) | ||
|
||
return h(StoreContext.Provider, Object.assign({ value: store }, rest)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Map props.store
to the context provider's expected prop, value
.
@@ -48,4 +56,8 @@ export const connect = (...args) => { | |||
return h(Comp, Object.assign({}, props, state, this.actionCreators)) | |||
} | |||
} | |||
|
|||
return (props) => h(StoreContext.Consumer, undefined, (store) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only way to consume context in the new API is through the context Consumer
or the useContext
hook. This seems like the simplest solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this, very clean.
context
API, which this package uses to pass downstore
. Aconnect
-ed component doesn't appear to render at all!createContext
export and its consumer and provider.npm test
!Note: This PR should probably correspond to changing
peerDependencies.preact
to>=10.x.x
in the package.json. I should be published to npm with anext
tag or major version bump.