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

make Autosizer not pure since it always re-renders anyway because it receives children as function #1490

Merged
merged 1 commit into from
Mar 12, 2020
Merged

Conversation

vzaidman
Copy link
Contributor

@vzaidman vzaidman commented Feb 2, 2020

Since the suggested use of the AutoSizer is passing an inline function to it, it doesn't makes sense the AutoSizer component is pure, since it would re-render anyway:

  <AutoSizer>
    {({height, width}) => (
      // this is a new function on each render.
    )}
  </AutoSizer>,

If anybody wants to make it pure, they still can:

const PureAutoSizer = React.memo(AutoSizer);
  • [ x ] The existing test suites (npm test) all pass
  • [ x ] For any new features or bug fixes, both positive and negative test cases have been added
  • [ x ] For any new features, documentation has been added
    Should i document it?
  • [ x ] For any documentation changes, the text has been proofread and is clear to both experienced users and beginners.
  • [ x ] Format your code with prettier (yarn run prettier).
  • [ x ] Run the Flow typechecks (yarn run typecheck).

Here is a short checklist of additional things to keep in mind before submitting:

  • Please make sure your pull request description makes it very clear what you're trying to accomplish. If it's a bug fix, please also provide a failing test case (if possible). In either case, please add additional unit test coverage for your changes. :)
  • Be sure you have notifications setup so that you'll see my code review responses. (I may ask you to make some adjustments before merging.)

@codecov-io
Copy link

Codecov Report

Merging #1490 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1490   +/-   ##
=======================================
  Coverage   94.66%   94.66%           
=======================================
  Files          47       47           
  Lines        1801     1801           
=======================================
  Hits         1705     1705           
  Misses         96       96
Impacted Files Coverage Δ
source/AutoSizer/AutoSizer.js 100% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dc9e2dd...e5866f0. Read the comment docs.

@wuweiweiwu
Copy link
Contributor

although this problem can be alleviated by pulling the function outside it makes passing props to the render prop more complex.

Thanks for the contribution!

@wuweiweiwu wuweiweiwu merged commit 1a85f58 into bvaughn:master Mar 12, 2020
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.

3 participants