[Error: undefined is not a constructor (evaluating 'new _globalThis.TextEncoder()')] when using suggested crypto-hash in react-native 0.63.x
See original GitHub issueIntended outcome:
Follow the example and it works.
Actual outcome:
Follow the example and get this error:
[Error: undefined is not a constructor (evaluating 'new _globalThis.TextEncoder()')]
How to reproduce the issue:
Follow this example with an Apollo Client in React Native.
So far, everything has worked in both web and mobile as far as our Apollo Client usage until this. Is there a recommended alternative or is this a bug?
Versions
System:
OS: macOS 10.15.7
Binaries:
Node: 14.15.0 - ~/.nvm/versions/node/v14.15.0/bin/node
Yarn: 1.22.10 - ~/.nvm/versions/node/v14.15.0/bin/yarn
npm: 6.14.8 - ~/.nvm/versions/node/v14.15.0/bin/npm
Browsers:
Chrome: 89.0.4389.128
Safari: 14.1
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
(React-Native) undefined is not a constructor evaluating ' ...
The error says that you are FormData is undefined. Since it is not part of react native, you probably have to download it...
Read more >Passing props and undefined is not a constructor - Svelte
Just wiring up basic props and getting an error. ... TypeError: undefined is not a constructor (evaluating 'new Foo({ props: { number: 42...
Read more >jest typeerror: class extends value
When attempting to mock Stack with jest, a TypeError "Class extends value undefined is not a constructor or null" is thrown. I need...
Read more >react - ReactJS TypeError "not a constructor" on running a ...
ReactJS TypeError "not a constructor" on running a component with Carto ... This is the constructor of my React Component:
Read more >Understanding React Component Constructor
render(<Hello />, document.getElementById('container'));. When you use the setState() method in React, it does more than just assign a new value ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@eliw00d Apollo Client doesn’t use
TextEncoder
directly anywhere in our codebase, but perhaps you can track this down by defining a global getter function that shows the stack trace?I wouldn’t recommend leaving this getter in your application (this is just for debugging).
I was able to get it to work by using react-native-sha256.
I also tried this but was not able to get it to work (due to the reasons specified in my comment there).