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

React Context breaks app #1184

Closed
PutziSan opened this issue Feb 19, 2019 · 8 comments
Closed

React Context breaks app #1184

PutziSan opened this issue Feb 19, 2019 · 8 comments

Comments

@PutziSan
Copy link

Description

If you assign a provider to a variable, the app breaks with Invalid value used as weak map key:

import React from "react";

const Ctx = React.createContext();
const Prov = Ctx.Provider;

see codesandbox: https://codesandbox.io/s/5yr558ky0x

removing the line const Prov = Ctx.Provider; in src/App.js or ""react-hot-loader/babel" in .babelrc resolves the issue.

Environment

React Hot Loader version: 4.7.0

Reproducible Demo

https://codesandbox.io/s/5yr558ky0x

@dkadrios
Copy link

Ran into the same issue. Removing react-hot-loader/babel from .babelrc does indeed seem to resolve things, but I wonder what is the consequence of doing so?

@theKashey
Copy link
Collaborator

My bad. Trying to "register" "Provider.Provider"

@kog-7
Copy link

kog-7 commented Feb 20, 2019

I also encountered the same problem, if i remove react-hot-loader/babel,i can't use this hot again,how to solve?
Error as follows
`updateFunctionProxyById
./node_modules/react-hot-loader/dist/react-hot-loader.development.js:1034
1031 |
1032 | var updateFunctionProxyById = function updateFunctionProxyById(id, type, updater) {
1033 | // Remember the ID.

1034 | idsByType.set(type, id);
1035 | var proxy = proxiesByID[id];
1036 | if (!proxy) {
1037 | idsByType.set(type, id);`

@theKashey
Copy link
Collaborator

I'll push update today. It's a one-line change.

@kog-7
Copy link

kog-7 commented Feb 20, 2019

thanks,looking forward to

@theKashey
Copy link
Collaborator

47.1 released

@diondirza
Copy link

@theKashey I still got this error on my end with v4.7.1

react.development.js:188 Warning: Rendering <Context.Consumer.Provider> is not supported and will be removed in a future major release. Did you mean to render <Context.Provider> instead?

because I had context which destruct a consumer like this
const LocaleConsumer = LocaleContext.Consumer;.

Demo
https://codesandbox.io/s/6xpmnnl81n

@theKashey
Copy link
Collaborator

The patch is already here - #1190, just finishing something prior...

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

No branches or pull requests

5 participants