Closed czycha closed 6 years ago
Hi @czycha, I could easily export both default and a named function but this does not mean that it would work. Can you share some more info regarding your setup in order to experiment a little bit with that?
@valotas So here's an example repo that puts my plan into action: https://github.com/czycha/example-preact-unstated. It uses a packed version of my fork in place of preact-context. Basically the example repository uses the React state management system Unstated which would usually depend on create-react-context. By changing up the Webpack config (see above comment), I can just have it alias that module with preact-context and it works perfectly!
Thanks a lot for putting it together. It looks like webpack can handle export.default
just fine, so I'll release a fix later today.
Hi! This module is great but I have one very minor suggestion. If you change how
createContext
is exported, this module can then be used as a drop-in replacement for React components that use create-react-context (in the same way that you can drop-in preact-compat to replace react-dom).For example, in Webpack you could do something like:
However, since create-react-context exports on
default
and preact-context exports oncreateContext
, this is not possible without something hacky.This would be a breaking change so I understand if you'd want to refrain from doing this.