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

feat(Responsive): re render only on visibility or props change #3274

Merged
merged 4 commits into from
Nov 25, 2018

Conversation

danielr18
Copy link
Contributor

Instead of computing isVisible() on render, it's better to have its value in the state, as it avoids:

  • shouldComponentUpdate logic
  • re rendering on every width change, when its value is only used to check if it's visible

By having isVisible in state, the component only renders when you update isVisible and when props change. I also made sure that isVisible is recomputed if the props it depends on change.

@welcome
Copy link

welcome bot commented Nov 12, 2018

💖 Thanks for opening this pull request! 💖

Here is a list of things that will help get it across the finish line:

  • Run yarn lint locally to catch formatting errors. This will fix some errors automatically, commit and push any changes.
  • Run yarn test locally to catch errors. This ensures all components still behave as they should.
  • Run yarn start to run the doc site locally and try a few pages, ensuring everything is in good working order.
  • Include tests when adding/changing behavior.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

@codecov-io
Copy link

codecov-io commented Nov 12, 2018

Codecov Report

Merging #3274 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3274   +/-   ##
=======================================
  Coverage   99.92%   99.92%           
=======================================
  Files         169      170    +1     
  Lines        2803     2803           
=======================================
  Hits         2801     2801           
  Misses          2        2
Impacted Files Coverage Δ
src/addons/Responsive/Responsive.js 100% <100%> (ø) ⬆️
src/addons/Responsive/lib/isVisible.js 100% <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 fca4035...8953785. Read the comment docs.

@layershifter
Copy link
Member

@danielr18 I made some changes, can you please check?

@danielr18
Copy link
Contributor Author

Changes look good

@layershifter layershifter merged commit 94711d3 into Semantic-Org:master Nov 25, 2018
@welcome
Copy link

welcome bot commented Nov 25, 2018

Congrats on merging your first pull request! 🎉🎉🎉

robot victory dance

@danielr18 danielr18 deleted the feat/responsive-perf branch November 25, 2018 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants