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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Immer breaks in browsers with Proxy support if they don't have Proxy.revocable #435

Closed
1 of 2 tasks
esturcke opened this issue Oct 4, 2019 · 2 comments 路 Fixed by node-gh/gh#728
Closed
1 of 2 tasks
Labels

Comments

@esturcke
Copy link
Contributor

esturcke commented Oct 4, 2019

馃悰 Bug Report

Immer does not work in browser with support for Proxy, but not Proxy.revocable, for example Firefox 24 (which we unfortunately need to support).

Firefox 24 reports:

[10:05:11.037] TypeError: Proxy.revocable is not a function @ http://10.151.32.17:5000/static/js/2.078cae13.chunk.js:1

To Reproduce

  • git clone git@github.com:esturcke/bug-immer-ff24.git
  • yarn build
  • serve -s build
  • Access the page in Firefox 24

Expected behavior

The page should render "Hello Immer".

Link to repro

https://github.com/esturcke/bug-immer-ff24

Environment

  • Immer version: 4.0.0
  • Occurs with setUseProxies(true)
  • Occurs with setUseProxies(false) (ES5 only)

Potential Fix

Maybe fall back in the non-Proxy version if Proxy.revocable is undefined:

@@ -19,7 +19,7 @@ import {ImmerScope} from "./scope"
 function verifyMinified() {}

 const configDefaults = {
-	useProxies: typeof Proxy !== "undefined" && typeof Reflect !== "undefined",
+	useProxies: typeof Proxy !== "undefined" && typeof Proxy.revocable !== "undefined" && typeof Reflect !== "undefined",
 	autoFreeze:
 		typeof process !== "undefined"
 			? process.env.NODE_ENV !== "production"
@esturcke esturcke changed the title Immer breaks in browsers with Proxy support if they don't have Proxy.revocable` Immer breaks in browsers with Proxy support if they don't have Proxy.revocable Oct 4, 2019
mweststrate added a commit that referenced this issue Oct 4, 2019
Use legacy proxies if Proxy.revocable is not defined. Fixes #435
@aleclarson
Copy link
Member

馃帀 This issue has been resolved in version 4.0.1 馃帀

The release is available on:

Your semantic-release bot 馃摝馃殌

@MuhammadAffanWahid
Copy link

const [state, dispatch] = useImmerReducer(reducer, initialState);
On the above line I get the error Proxy.revocable is not a function.

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

Successfully merging a pull request may close this issue.

3 participants