Skip to content
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

inferno-compat issue: TypeError: _react.default.createContext is not a function #1483

Open
dessalines opened this issue Aug 5, 2019 · 3 comments

Comments

@dessalines
Copy link
Contributor

dessalines commented Aug 5, 2019

Versions:

"inferno": "^7.2.1",
"inferno-clone-vnode": "^7.2.1",
"inferno-compat": "^7.2.1",
"inferno-clone-vnode": "^7.2.1",
"inferno-create-class": "^7.2.1",
"inferno-create-element": "^7.2.1",

Arch linux
node `v11.15.0`

I'm trying to internationalize an app I've written in inferno. I tried lingui, and failed, and now am trying i18next, using inferno-compat.

Observed Behaviour
After aliasing react and react-dom to inferno-compat, it correctly compiles, but gets the console error:

TypeError: _react.default.createContext is not a function

If I alias them to simply inferno, I get:

TypeError: _react.default is undefined

I should also say that I'm using inferno with typescript and fuse-box, and the aliasing is done in fuse-box, and it's working correctly.

Here's the example I'm working from, its straight .ts imports, no extra babel packaging or anything.

Really if anyone has found any i18n framework that works with inferno, I'd be happy to know which one.

@Havunen
Copy link
Member

Havunen commented Aug 5, 2019

What kind of functionality you need from i18next framework? We are sing i18next package and calling translate method there.

@dessalines
Copy link
Contributor Author

dessalines commented Aug 5, 2019

Translations, primarily the Trans tag and T tags, in JSX / TSX

I did find this project, which appears to have I18n support for inferno directly, but it doesn't have much documentation. https://github.com/nimbusec-oss/inferno-i18next

After I add some typings for it I'll be able to test it out.

@simonjoom
Copy link

simonjoom commented Aug 15, 2019

like preact you need the polyfill version of react-context.
install in your deps:
create-react-context (https://github.com/jamiebuilds/create-react-context)

and if you build with web pack
add an alias:
"create-react-context": node_module/create-react-context,

if still not working;
manually find all package using react.createContext and be sure it's pointing to the create-react-context you installed. (me i did that and it's working great now with lot of deps using the context)

Maybe it will be good to add a inferno-context like preact-context do (easy just simply copy create-react-context')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants