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

Avoid functions as children #21

Closed
3 tasks done
staydecent opened this issue Feb 14, 2019 · 2 comments
Closed
3 tasks done

Avoid functions as children #21

staydecent opened this issue Feb 14, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@staydecent
Copy link
Contributor

staydecent commented Feb 14, 2019

On several occasions I've run into issues where React is not reconciling functions as children when props change. This is hard to reproduce in an arbitrary example, but usually found deep in a project.

There have been several potentially related issues on the React project, with core devs usually mentioning that quite a bit of extra work is done in React core to handle different children types. Most cases are optimized for actual Components/JSX elements.

To avoid potential bugs, performance drawbacks, and improve clarity of code, functions as children should be avoided.

  • WithRequest
  • WithState
  • ListResource

https://americanexpress.io/faccs-are-an-antipattern/
facebook/react#12715
facebook/react#11888
facebook/react#7806
facebook/react#4136 (comment)

@staydecent staydecent added the enhancement New feature or request label Feb 14, 2019
@staydecent
Copy link
Contributor Author

Example of migrating away from function as children resulting in the app properly updated UI: https://github.com/inputlogic/neighbors-mobile/pull/107

@staydecent
Copy link
Contributor Author

Closed by 8d019f3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant