React Native - warn message sends Can't find variable: TextEncoder
See original GitHub issueI am using Stompjs to connect with Apache ActiveMQ and Spring Server but when I run application I receive a console warning message and after I navigate to another Screen with lots of data I receive this error non-stop as if it went to a loop.
Error:
[Unhandled promise rejection: ReferenceError: Can't find variable: TextEncoder]
- node_modules/@stomp/stompjs/bundles/stomp.umd.js:1538:30 in Parser
- node_modules/@stomp/stompjs/bundles/stomp.umd.js:1832:16 in start
- ... 13 more stack frames from framework internals
I believe this has to do with the package rather than my code
const stompConfig = {
reconnectDelay: 100,
heartbeatIncoming: 0,
heartbeatOutgoing: 0,
debug: function(str) {
console.log(str);
}
}
stompConfig.webSocketFactory = () => {
return new SockJS(
"http://192.168.1.2:8080/"
);
};
client = new Client(stompConfig);
client.onConnect = function(frame) {
console.log('frame', frame.body);
};
client.onStompError = function(frame) {
console.log('Broker reported error: ', frame.headers['message']);
console.log('Additional details: ', frame.body);
};
client.activate();
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:12 (5 by maintainers)
Top Results From Across the Web
ReferenceError: Can't find variable: TextEncoder
I got the same error using stomp.js socket. All I did was put. import * as encoding from 'text-encoding';. in App.js and works...
Read more >Web terminals don't work in Safari: `ReferenceError: can't find ...
Web terminals don't work in Safari: `ReferenceError: can't find variable: TextDecoder`. Summary. Web terminals raise a JavaScript error if ...
Read more >Configuring Jest
All modules used in your tests will have a replacement implementation, keeping the API surface. Example: utils.js. export default {
Read more >Node.js v19.3.0 Documentation
Environment variable options; Persistent history; Using the Node.js REPL with advanced line-editors; Starting multiple REPL instances against a single ...
Read more >Edge Runtime
The Next.js Edge Runtime is based on standard Web APIs. ... your code could contain (or import) some dynamic code evaluation statements which...
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 Free
Top 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
Please try https://stomp-js.github.io/guide/stompjs/rx-stomp/ng2-stompjs/2018/06/29/pollyfils-for-stompjs-v5.html
@kum-deepak thanks for the link @madsams thanks for telling where to focus 😃
React Native already supports WebSocket thus we only need to add text-encoder to global TextEncoder, TextDecoder objects: