-
Notifications
You must be signed in to change notification settings - Fork 1k
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
toISOString is not a function #315
Comments
Most likely you're passing a React Synthetic Event, which cannot be serialized. See the similar issue and the troubleshooting. Note that the solution in that issue will not be available in React 16, since we're relying on React internals. So, I recommend to choose one of the solutions from the troubleshooting. However, it would be great if we could make jsan not to throw in this case, but at least to skip those data. If you could add a pr with a test case there, it would be much appreciated. Seems like the issue with |
My guess is that React purges the events and the date's |
Yeah you're right. I had some infrastructure that actually passed a React Component in the payload of an action. When I changed this to a new object with only the specific properties I was looking for, the issue when away. So yes I believe the issue was actually the extension trying to parse a React Component. This is an avoidable issue from the consumer point of view, but I believe it would be good to perhaps add some sort of check for this, as you suggested. |
I know passing an React Component in an action sound like a bad idea and an anti pattern anyway, and I agree, but given the exact scenario it makes more sense. Perhaps even just a check throwing an error whenever encountering a React Component anywhere in the state or any action saying it's a bad idea would also do the trick. Great work on this extension btw. I wouldn't mind contributing should you guys need any more hands. |
Not sure that storing React Components inside states is anti pattern. Seems there are some cases where it cannot be avoided. I'd like to support this (by restoring the reference), but it wouldn't be by default for performance reason. So, we anyway should find a solution here. We should either find why |
I tried to whip up a quick example but did not get the same results. But basically it comes down to dispatching an action from a component's componentWillMount function passing "this" in the payload. |
Just to add to what @zalmoxisus was saying... I don't know much about synthetic events, however I do know that the d = new Date();
d.toISOString = null;
d.toJSON(); // Uncaught TypeError: toISOString is not a function This explains what is happening (probably) but not why it's happening |
Same issue here. Side-note: As a development tool, the extension throwing errors in the console is confusing. Perhaps that section that is throwing error should be in try-catch and the error itself should be confined to the extensions's own view panel. |
I got the same issue when using the extension together with |
@etse, could you please provide a repro so I'd find a way to bypass the exception. Maybe a pr modifying one of our examples? |
I wasn't able to reproduce the issue with Neither React nor |
I have the same issue using the Chrome extension version 2.15.0, any update on how to avoid this issue? Below is my configureStore file:
|
@daraclare it usually happens when you pass a React synthetic event as an action payload. See Troubleshooting for more information on how to solve this. Let me know if it helps. |
I have an onclick event here:
but what I am making is a template to be used by other devs, so should I leave out the use of ReduxDevTools as the other developers will not know to change how they use synthetic events. If so, it seems like a shame, ReduxDevTools is so useful. Let me know what you think please? |
You should use it like that: export default class ReduxPage extends Component {
increment() {
this.props.actions.increment();
}
decrement() {
this.props.actions.decrement();
}
render() {
return (
<div className="reduxpage">
<h1>React & Redux Example</h1>
<h1>{this.props.counter}</h1>
<button onClick={this.increment}> + </button>
<button onClick={this.decrement}> - </button>
</div>
);
}
} In this way there's no event payload sent to the actions. I know it looks cumbersome, but if there're lots of actions to call you can use one function which would call one of them depending on the event data. |
Thanks very much for the above, that was exactly the problem :) |
I was having the same issue as @justusburger - storing a React component in redux was throwing this error. The solution that worked for me was giving the React component in question a export class MyComponent extends Component {
toJSON(){
return "This will appear in redux dev tools"
}
render(){
return(
<div></div>
)
}
} This overrides the default It would be nice if Tried to throw together a minimal failing test, but haven't gotten it working yet. |
We've removed event payload as suggested here by @zalmoxisus
..and error is gone. |
I comment the "import 'core-js/es6/date';" in my polyfils.ts, then everything is ok. |
It should be handled in |
Since a few days ago, whenever I load my React + Redux app with the dev tools open, I get an error in the console saying:
Uncaught TypeError: toISOString is not a function
at String.toJSON ()
When I disable the Redux extension the error goes away. I suspect the issue has todo with the extension trying to parse/format my redux state and there is something that's causing issues.
The app I'm building is isomorphic, so I pass my store's initial state in a script tag. I would imagine that you'll be able to recreate the issue by simply trying to parse my initial state with the extension's parsing function.
Note that I do run the state.app section through immutable.fromJS on the client just before seeding the new store.
Im happy to send you the link to the site in question in a DM or something, just not 100% comfortable with posting it here.
The text was updated successfully, but these errors were encountered: