Skip to content
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

Chore(ReactVis): Remove String Refs #840

Merged
merged 1 commit into from
Jun 27, 2018
Merged

Chore(ReactVis): Remove String Refs #840

merged 1 commit into from
Jun 27, 2018

Conversation

benshope
Copy link
Contributor

@benshope benshope commented Jun 26, 2018

I just ran into #736 and this will probably fix it

@radumiron
Copy link

Wow, I'm looking forward to see the build pass on this one!

@jckr
Copy link
Contributor

jckr commented Jun 26, 2018

Thanks @benshope for taking this on!

@benshope
Copy link
Contributor Author

@radumiron yea I pushed this branch before checking the tests, I'll fix those!
@jckr 👍

@benshope
Copy link
Contributor Author

@jckr should I use normal methods instead of arrow functions for perf reasons?

@mcnuttandrew
Copy link
Contributor

@jckr should I use normal methods instead of arrow functions for perf reasons?

Using arrow function vs explicit functions shouldn't change anything right? It's all passed through babel and transpiled into straight old fashioned js

@benshope
Copy link
Contributor Author

benshope commented Jun 27, 2018

@mcnuttandrew yea I guess it's probably fine here. I had read a few headlines about arrow functions in render being an issue https://medium.freecodecamp.org/why-arrow-functions-and-bind-in-reacts-render-are-problematic-f1c08b060e36 and figured that would apply here - but I guess that article is saying they're mostly problematic higher in the tree when trying to prevent unnecessary refreshes. Good to ship this if you're cool with it!

@mcnuttandrew
Copy link
Contributor

Yea seems good! This feels like this might be a kinda significant change, so maybe do a minor bump

@mcnuttandrew mcnuttandrew merged commit 167701b into uber:master Jun 27, 2018
@ericsoco
Copy link

ericsoco commented Jul 2, 2018

@benshope the issue is not with arrow functions in render, it's any function declared in within render. The issue is that React compares current props with previous, sees that the function created last pass !== the fn created this pass, and therefore rerenders the component tree from there down.

Doesn't matter if it's an arrow func or pre-ES6 inline func, just that it's declared within render.

Ideally, callbacks-as-props are declared once, as a member of the React class or outside of the class def, and params are passed to it. This is not always possible, i.e. when context from within render needs to be passed in and can't be pulled e.g. off of this.props. In that case, you just accept the hopefully-minor perf hit.

ayarcohaila pushed a commit to ayarcohaila/react-vis that referenced this pull request Jun 30, 2021
ayarcohaila added a commit to ayarcohaila/react-vis that referenced this pull request May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants