ReactJS websocket results get translated by i18nHow do you get a timestamp in JavaScript?How to get the children of the $(this) selector?Get current URL with jQuery?How can I get query string values in JavaScript?Get the current URL with JavaScript?How do I get the current date in JavaScript?Get selected text from a drop-down list (select box) using jQueryGet the size of the screen, current web page and browser windowWebSockets vs. Server-Sent events/EventSourceWhat are Long-Polling, Websockets, Server-Sent Events (SSE) and Comet?

Wordplay subtraction paradox

Why is Google approaching my VPS machine?

ArcPy Delete Function not working inside for loop?

How can electric field be defined as force per charge, if the charge makes its own, singular electric field?

What is the difference between a Hosaka, Ono-Sendai, and a "deck"?

How would you say "Sorry, that was a mistake on my part"?

Improve quality of image bars

Intel 8080-based home computers

Can a Resident Assistant be told to ignore a lawful order?'

Cauchy reals and Dedekind reals satisfy "the same mathematical theorems"

Migrating Configuration - 3750G to 3750X

How many bits in the resultant hash will change, if the x bits are changed in its the original input?

Preview an archive contents without extracting it

Is passive Investigation essentially truesight against illusions?

Will this tire fail its MOT?

Is it okay for a chapter's POV to shift as it progresses?

Cover a cube with four-legged walky-squares!

what relax command means?

How fast does a character need to move to be effectively invisible?

At which point can a system be compromised when downloading archived data from an untrusted source?

Why do so many pure math PhD students drop out or leave academia, compared to applied mathematics PhDs?

What "fuel more powerful than anything the West (had) in stock" put Laika in orbit aboard Sputnik 2?

My credit card has no magnetic stripe. Is this a problem in the USA?

Is it rude to refer to janitors as 'floor people'?



ReactJS websocket results get translated by i18n


How do you get a timestamp in JavaScript?How to get the children of the $(this) selector?Get current URL with jQuery?How can I get query string values in JavaScript?Get the current URL with JavaScript?How do I get the current date in JavaScript?Get selected text from a drop-down list (select box) using jQueryGet the size of the screen, current web page and browser windowWebSockets vs. Server-Sent events/EventSourceWhat are Long-Polling, Websockets, Server-Sent Events (SSE) and Comet?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have a ReactJS webapp where I use webscokets to retrieve ticker prices from an API. When my webapp is standalone it works perfectly you can see in the image below.



1



But when I try to merge it in to my main react web app which has i18n localization no matter what I do I get this result. It seems it get stuck in the array or something. Maybe anyone has a clue how could I tackle this problem?
2



import React from 'react'
import axios from 'axios'
import connect from 'react-redux'
import Loading from '../elements/Loading'
import Ticker from './Ticker'
import TradeHistory from './TradeHistory'
import OrderBook from './OrderBook'

class Trade extends React.Component

constructor(props)
super(props);
this.state =
isLoaded: false
;
this.tradesCount = 20;
this.streams = ['@ticker','@depth20','@trade'];


_connectSocketStreams(streams)
streams = streams.join('/');
let connection = btoa(streams);
this[connection] = new WebSocket(`wss://stream.binance.com:9443/stream?streams=$streams`);
this[connection].onmessage = evt =>
let eventData = JSON.parse(evt.data);
if(eventData.stream.endsWith('@ticker'))
eventData.data.lastc = this.state.ticker ? this.state.ticker.c : 0
this.props.dispatch(
type: 'SET_TICKER',
data: eventData.data
)
this.setState(
loadedTicker: true
)

if(eventData.stream.endsWith('@trade'))
if(this.props.trades && Object.keys(this.props.trades).length > 0)
let trades = this.props.trades;
trades.push(eventData.data);
trades = trades.slice(-1*this.tradesCount);
this.props.dispatch(
type: 'SET_TRADES',
data: trades
)
this.setState(
loadedTrades: true
)


if(eventData.stream.endsWith('@depth20'))
this.props.dispatch(
type: 'SET_DEPTH',
data: eventData.data
)
this.setState(
loadedDepth: true
)

this.setState(
isLoaded: true
)
;
this[connection].onerror = evt =>
console.error(evt);



_disconnectSocketStreams(streams)
streams = streams.join('/');
let connection = btoa(streams);
if (this[connection].readyState === WebSocket.OPEN)
this[connection].close();



componentDidMount()

let symbol = this.props.match.params.symbol.toLowerCase();
this._connectSocketStreams(this.streams.map(i => `$symbol$i`));

axios(
method: 'get',
url: `https://cors-anywhere.herokuapp.com/https://www.binance.com/api/v1/aggTrades?limit=$this.tradesCount&symbol=$this.props.match.params.symbol`
)
.then(response =>
this.props.dispatch(
type: 'SET_TRADES',
data: response.data
)
this.setState(
isLoaded: true,
loadedTrades: true
)
)
.catch(error =>
this.setState(
isLoaded: false,
error: error
)
);


componentWillUnmount()
let symbol = this.props.match.params.symbol.toLowerCase();
this._disconnectSocketStreams(this.streams.map(i => `$symbol$i`))


render()
const error, isLoaded, loadedDepth, loadedTicker, loadedTrades = this.state;
if (error)
return <div className="alert alert-danger">error.message</div>;

if (!isLoaded)
return <Loading />;

return (
<React.Fragment>
<div className="row">
<div className="col-12">loadedTicker ? <Ticker ...this.props.ticker /> : <Loading /></div>
</div>
<div className="row">
<div className="col-12 col-sm-6">loadedTrades ? <TradeHistory trades=this.props.trades/> : <Loading /></div>
</div>
</React.Fragment>
)




export default connect(
state => state
)(Trade)









share|improve this question
























  • please share us some code on how you integrated with your existing app

    – Ori Price
    Mar 26 at 9:38











  • @OriPrice poster my ticker class I also have a few more reducer and so on. Just that it is working perfectly when it is stand alone but as soon as I merge it does not work any more.

    – Andrew
    Mar 26 at 9:44












  • probably you have some i18n HOC over your component that translate you props somehow

    – Ori Price
    Mar 26 at 9:47











  • @OriPrice is there a way to prohibit translations of certain components?

    – Andrew
    Mar 26 at 9:50











  • first, we need to find out how its getting translated. it shouldn't be translated automatically. could you share the way you consume Ticker component?

    – Ori Price
    Mar 26 at 9:51


















0















I have a ReactJS webapp where I use webscokets to retrieve ticker prices from an API. When my webapp is standalone it works perfectly you can see in the image below.



1



But when I try to merge it in to my main react web app which has i18n localization no matter what I do I get this result. It seems it get stuck in the array or something. Maybe anyone has a clue how could I tackle this problem?
2



import React from 'react'
import axios from 'axios'
import connect from 'react-redux'
import Loading from '../elements/Loading'
import Ticker from './Ticker'
import TradeHistory from './TradeHistory'
import OrderBook from './OrderBook'

class Trade extends React.Component

constructor(props)
super(props);
this.state =
isLoaded: false
;
this.tradesCount = 20;
this.streams = ['@ticker','@depth20','@trade'];


_connectSocketStreams(streams)
streams = streams.join('/');
let connection = btoa(streams);
this[connection] = new WebSocket(`wss://stream.binance.com:9443/stream?streams=$streams`);
this[connection].onmessage = evt =>
let eventData = JSON.parse(evt.data);
if(eventData.stream.endsWith('@ticker'))
eventData.data.lastc = this.state.ticker ? this.state.ticker.c : 0
this.props.dispatch(
type: 'SET_TICKER',
data: eventData.data
)
this.setState(
loadedTicker: true
)

if(eventData.stream.endsWith('@trade'))
if(this.props.trades && Object.keys(this.props.trades).length > 0)
let trades = this.props.trades;
trades.push(eventData.data);
trades = trades.slice(-1*this.tradesCount);
this.props.dispatch(
type: 'SET_TRADES',
data: trades
)
this.setState(
loadedTrades: true
)


if(eventData.stream.endsWith('@depth20'))
this.props.dispatch(
type: 'SET_DEPTH',
data: eventData.data
)
this.setState(
loadedDepth: true
)

this.setState(
isLoaded: true
)
;
this[connection].onerror = evt =>
console.error(evt);



_disconnectSocketStreams(streams)
streams = streams.join('/');
let connection = btoa(streams);
if (this[connection].readyState === WebSocket.OPEN)
this[connection].close();



componentDidMount()

let symbol = this.props.match.params.symbol.toLowerCase();
this._connectSocketStreams(this.streams.map(i => `$symbol$i`));

axios(
method: 'get',
url: `https://cors-anywhere.herokuapp.com/https://www.binance.com/api/v1/aggTrades?limit=$this.tradesCount&symbol=$this.props.match.params.symbol`
)
.then(response =>
this.props.dispatch(
type: 'SET_TRADES',
data: response.data
)
this.setState(
isLoaded: true,
loadedTrades: true
)
)
.catch(error =>
this.setState(
isLoaded: false,
error: error
)
);


componentWillUnmount()
let symbol = this.props.match.params.symbol.toLowerCase();
this._disconnectSocketStreams(this.streams.map(i => `$symbol$i`))


render()
const error, isLoaded, loadedDepth, loadedTicker, loadedTrades = this.state;
if (error)
return <div className="alert alert-danger">error.message</div>;

if (!isLoaded)
return <Loading />;

return (
<React.Fragment>
<div className="row">
<div className="col-12">loadedTicker ? <Ticker ...this.props.ticker /> : <Loading /></div>
</div>
<div className="row">
<div className="col-12 col-sm-6">loadedTrades ? <TradeHistory trades=this.props.trades/> : <Loading /></div>
</div>
</React.Fragment>
)




export default connect(
state => state
)(Trade)









share|improve this question
























  • please share us some code on how you integrated with your existing app

    – Ori Price
    Mar 26 at 9:38











  • @OriPrice poster my ticker class I also have a few more reducer and so on. Just that it is working perfectly when it is stand alone but as soon as I merge it does not work any more.

    – Andrew
    Mar 26 at 9:44












  • probably you have some i18n HOC over your component that translate you props somehow

    – Ori Price
    Mar 26 at 9:47











  • @OriPrice is there a way to prohibit translations of certain components?

    – Andrew
    Mar 26 at 9:50











  • first, we need to find out how its getting translated. it shouldn't be translated automatically. could you share the way you consume Ticker component?

    – Ori Price
    Mar 26 at 9:51














0












0








0








I have a ReactJS webapp where I use webscokets to retrieve ticker prices from an API. When my webapp is standalone it works perfectly you can see in the image below.



1



But when I try to merge it in to my main react web app which has i18n localization no matter what I do I get this result. It seems it get stuck in the array or something. Maybe anyone has a clue how could I tackle this problem?
2



import React from 'react'
import axios from 'axios'
import connect from 'react-redux'
import Loading from '../elements/Loading'
import Ticker from './Ticker'
import TradeHistory from './TradeHistory'
import OrderBook from './OrderBook'

class Trade extends React.Component

constructor(props)
super(props);
this.state =
isLoaded: false
;
this.tradesCount = 20;
this.streams = ['@ticker','@depth20','@trade'];


_connectSocketStreams(streams)
streams = streams.join('/');
let connection = btoa(streams);
this[connection] = new WebSocket(`wss://stream.binance.com:9443/stream?streams=$streams`);
this[connection].onmessage = evt =>
let eventData = JSON.parse(evt.data);
if(eventData.stream.endsWith('@ticker'))
eventData.data.lastc = this.state.ticker ? this.state.ticker.c : 0
this.props.dispatch(
type: 'SET_TICKER',
data: eventData.data
)
this.setState(
loadedTicker: true
)

if(eventData.stream.endsWith('@trade'))
if(this.props.trades && Object.keys(this.props.trades).length > 0)
let trades = this.props.trades;
trades.push(eventData.data);
trades = trades.slice(-1*this.tradesCount);
this.props.dispatch(
type: 'SET_TRADES',
data: trades
)
this.setState(
loadedTrades: true
)


if(eventData.stream.endsWith('@depth20'))
this.props.dispatch(
type: 'SET_DEPTH',
data: eventData.data
)
this.setState(
loadedDepth: true
)

this.setState(
isLoaded: true
)
;
this[connection].onerror = evt =>
console.error(evt);



_disconnectSocketStreams(streams)
streams = streams.join('/');
let connection = btoa(streams);
if (this[connection].readyState === WebSocket.OPEN)
this[connection].close();



componentDidMount()

let symbol = this.props.match.params.symbol.toLowerCase();
this._connectSocketStreams(this.streams.map(i => `$symbol$i`));

axios(
method: 'get',
url: `https://cors-anywhere.herokuapp.com/https://www.binance.com/api/v1/aggTrades?limit=$this.tradesCount&symbol=$this.props.match.params.symbol`
)
.then(response =>
this.props.dispatch(
type: 'SET_TRADES',
data: response.data
)
this.setState(
isLoaded: true,
loadedTrades: true
)
)
.catch(error =>
this.setState(
isLoaded: false,
error: error
)
);


componentWillUnmount()
let symbol = this.props.match.params.symbol.toLowerCase();
this._disconnectSocketStreams(this.streams.map(i => `$symbol$i`))


render()
const error, isLoaded, loadedDepth, loadedTicker, loadedTrades = this.state;
if (error)
return <div className="alert alert-danger">error.message</div>;

if (!isLoaded)
return <Loading />;

return (
<React.Fragment>
<div className="row">
<div className="col-12">loadedTicker ? <Ticker ...this.props.ticker /> : <Loading /></div>
</div>
<div className="row">
<div className="col-12 col-sm-6">loadedTrades ? <TradeHistory trades=this.props.trades/> : <Loading /></div>
</div>
</React.Fragment>
)




export default connect(
state => state
)(Trade)









share|improve this question
















I have a ReactJS webapp where I use webscokets to retrieve ticker prices from an API. When my webapp is standalone it works perfectly you can see in the image below.



1



But when I try to merge it in to my main react web app which has i18n localization no matter what I do I get this result. It seems it get stuck in the array or something. Maybe anyone has a clue how could I tackle this problem?
2



import React from 'react'
import axios from 'axios'
import connect from 'react-redux'
import Loading from '../elements/Loading'
import Ticker from './Ticker'
import TradeHistory from './TradeHistory'
import OrderBook from './OrderBook'

class Trade extends React.Component

constructor(props)
super(props);
this.state =
isLoaded: false
;
this.tradesCount = 20;
this.streams = ['@ticker','@depth20','@trade'];


_connectSocketStreams(streams)
streams = streams.join('/');
let connection = btoa(streams);
this[connection] = new WebSocket(`wss://stream.binance.com:9443/stream?streams=$streams`);
this[connection].onmessage = evt =>
let eventData = JSON.parse(evt.data);
if(eventData.stream.endsWith('@ticker'))
eventData.data.lastc = this.state.ticker ? this.state.ticker.c : 0
this.props.dispatch(
type: 'SET_TICKER',
data: eventData.data
)
this.setState(
loadedTicker: true
)

if(eventData.stream.endsWith('@trade'))
if(this.props.trades && Object.keys(this.props.trades).length > 0)
let trades = this.props.trades;
trades.push(eventData.data);
trades = trades.slice(-1*this.tradesCount);
this.props.dispatch(
type: 'SET_TRADES',
data: trades
)
this.setState(
loadedTrades: true
)


if(eventData.stream.endsWith('@depth20'))
this.props.dispatch(
type: 'SET_DEPTH',
data: eventData.data
)
this.setState(
loadedDepth: true
)

this.setState(
isLoaded: true
)
;
this[connection].onerror = evt =>
console.error(evt);



_disconnectSocketStreams(streams)
streams = streams.join('/');
let connection = btoa(streams);
if (this[connection].readyState === WebSocket.OPEN)
this[connection].close();



componentDidMount()

let symbol = this.props.match.params.symbol.toLowerCase();
this._connectSocketStreams(this.streams.map(i => `$symbol$i`));

axios(
method: 'get',
url: `https://cors-anywhere.herokuapp.com/https://www.binance.com/api/v1/aggTrades?limit=$this.tradesCount&symbol=$this.props.match.params.symbol`
)
.then(response =>
this.props.dispatch(
type: 'SET_TRADES',
data: response.data
)
this.setState(
isLoaded: true,
loadedTrades: true
)
)
.catch(error =>
this.setState(
isLoaded: false,
error: error
)
);


componentWillUnmount()
let symbol = this.props.match.params.symbol.toLowerCase();
this._disconnectSocketStreams(this.streams.map(i => `$symbol$i`))


render()
const error, isLoaded, loadedDepth, loadedTicker, loadedTrades = this.state;
if (error)
return <div className="alert alert-danger">error.message</div>;

if (!isLoaded)
return <Loading />;

return (
<React.Fragment>
<div className="row">
<div className="col-12">loadedTicker ? <Ticker ...this.props.ticker /> : <Loading /></div>
</div>
<div className="row">
<div className="col-12 col-sm-6">loadedTrades ? <TradeHistory trades=this.props.trades/> : <Loading /></div>
</div>
</React.Fragment>
)




export default connect(
state => state
)(Trade)






javascript reactjs api react-native websocket






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 26 at 9:55







Andrew

















asked Mar 26 at 9:03









AndrewAndrew

306 bronze badges




306 bronze badges












  • please share us some code on how you integrated with your existing app

    – Ori Price
    Mar 26 at 9:38











  • @OriPrice poster my ticker class I also have a few more reducer and so on. Just that it is working perfectly when it is stand alone but as soon as I merge it does not work any more.

    – Andrew
    Mar 26 at 9:44












  • probably you have some i18n HOC over your component that translate you props somehow

    – Ori Price
    Mar 26 at 9:47











  • @OriPrice is there a way to prohibit translations of certain components?

    – Andrew
    Mar 26 at 9:50











  • first, we need to find out how its getting translated. it shouldn't be translated automatically. could you share the way you consume Ticker component?

    – Ori Price
    Mar 26 at 9:51


















  • please share us some code on how you integrated with your existing app

    – Ori Price
    Mar 26 at 9:38











  • @OriPrice poster my ticker class I also have a few more reducer and so on. Just that it is working perfectly when it is stand alone but as soon as I merge it does not work any more.

    – Andrew
    Mar 26 at 9:44












  • probably you have some i18n HOC over your component that translate you props somehow

    – Ori Price
    Mar 26 at 9:47











  • @OriPrice is there a way to prohibit translations of certain components?

    – Andrew
    Mar 26 at 9:50











  • first, we need to find out how its getting translated. it shouldn't be translated automatically. could you share the way you consume Ticker component?

    – Ori Price
    Mar 26 at 9:51

















please share us some code on how you integrated with your existing app

– Ori Price
Mar 26 at 9:38





please share us some code on how you integrated with your existing app

– Ori Price
Mar 26 at 9:38













@OriPrice poster my ticker class I also have a few more reducer and so on. Just that it is working perfectly when it is stand alone but as soon as I merge it does not work any more.

– Andrew
Mar 26 at 9:44






@OriPrice poster my ticker class I also have a few more reducer and so on. Just that it is working perfectly when it is stand alone but as soon as I merge it does not work any more.

– Andrew
Mar 26 at 9:44














probably you have some i18n HOC over your component that translate you props somehow

– Ori Price
Mar 26 at 9:47





probably you have some i18n HOC over your component that translate you props somehow

– Ori Price
Mar 26 at 9:47













@OriPrice is there a way to prohibit translations of certain components?

– Andrew
Mar 26 at 9:50





@OriPrice is there a way to prohibit translations of certain components?

– Andrew
Mar 26 at 9:50













first, we need to find out how its getting translated. it shouldn't be translated automatically. could you share the way you consume Ticker component?

– Ori Price
Mar 26 at 9:51






first, we need to find out how its getting translated. it shouldn't be translated automatically. could you share the way you consume Ticker component?

– Ori Price
Mar 26 at 9:51













0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55353248%2freactjs-websocket-results-get-translated-by-i18n%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55353248%2freactjs-websocket-results-get-translated-by-i18n%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript