ctrlplusb / react-async-component

Resolve components asynchronously, with support for code splitting and advanced server side rendering use cases.
MIT License
1.45k stars 62 forks source link

Avoid unnecessary rerenders #85

Closed alexdor closed 5 years ago

alexdor commented 6 years ago

By extending React.PureComponent instead of React.Component reacts implements a shallow props comparison and avoids unnecessary rerenders.

codecov[bot] commented 6 years ago

Codecov Report

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

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #85   +/-   ##
=======================================
  Coverage   92.59%   92.59%           
=======================================
  Files           3        3           
  Lines          81       81           
  Branches       24       24           
=======================================
  Hits           75       75           
  Misses          6        6
Impacted Files Coverage Δ
src/asyncComponent.js 90.47% <100%> (ø) :arrow_up:

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 09935a2...8d6a434. Read the comment docs.

alexdor commented 6 years ago

@ctrlplusb I could make a different component (asyncPureComponent for example) instead of modifying the existing one if you want

mgreer commented 6 years ago

IMHO, forcing PureComponent is bad practice. Only use in cases where needed, since it creates spooky bugs in more complex applications (those that listen to context changes, or are tied to stores later on). Easy enough for consumers of this lib to use PureComponent themselves.