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
Converting circular structure to JSON #133
Comments
Hmm you are not alone. Someone else is having similar problem.. i need to revisit why i added that check in shouldComponentUpdate. |
@arolson101 Hey turns out that optimization was not needed anymore because i updated react form to use react-redux and it no longer used state. You should be all set now, get the latest version 2.1.1 and let me know it this problem is solved. |
Hmm although removing this may cause some performance issues in IE i think i will disable it by default and add an optimization flag. |
Ok so i removed this optimization by default but if you need it then pass in optimize prop. V2.1.2 |
Update: working on a solution that adds this optimization by default and does not have circular json issue. |
Ok so im now taking advantage of https://www.npmjs.com/package/circular-json so dont even worry about that temp solution. Your issue should be fixed now :) |
Thank you for your responsiveness! |
Have u updated and tried with the latest? Your og issue was that u were getting circular reference and u should not be any more. I could maybe add a flag thats says “dontOptimize” but trust me this will slow the form down the second u start getting big forms with lots of rendering |
Yes, this was on 2.1.5 |
Stringifying is the fastest way to deep compare in JS |
@joepuzzo, it seems like there must be a better way to handle these change detections. I would really love it if there was no stringification at all. Thoughts? |
I would simply loop over the keys of the old and new props, and detecting strict equality differences. As soon as you find a difference, you should bail out of the checking, so no time is wasted. I'll help you write this if you want. |
Hmm i have done reading on this before and it seemed like conclusion was json.stringify is the fastest most efficient way to do comparisons on complex objects.. is this wrong ? |
Here is a good summary of the stringify equality: http://www.mattzeunert.com/2016/01/28/javascript-deep-equal.html
|
Is there a reason for doing a deep equality rather than a shallow one? |
So this is a difficult problem to solve lol. React-form uses reacts context to give all FormFields access to the form api ( this is one of the most important parts of this lib ). Well this is very powerfull, it comes with the shitty side affect that you see in redux-form. Every single field will re-render. So in order to prevent this, the FormField takes advantage of reacts |
Ok i have done more reading and educated myself more lol.. i think the solution is what you posted @arolson101 http://www.mattzeunert.com/2016/01/28/javascript-deep-equal.html. |
@tannerlinsley it looks like the deepEqual function does exactly what you wanted to write |
While |
See #136 |
Checked out PRs and added some comments. We are close to resolution once those PRs are good to go. |
This should be fixed now that we're doing a shallow equality comparison :) |
2.2.0 is much better, thank you! |
I am passing a react element as a prop to a custom component like this:
this results in:
in
checkShouldComponentUpdate
it's testingJSON.stringify(a) !== JSON.stringify(u)
. I'm not quite sure why the structure is circular but it would be nice if this was supported in version 2 (it worked in version 1)The text was updated successfully, but these errors were encountered: