javascript - Pure ReactJS Components -
dan abramov says
...a component pure if guaranteed return same result given same props , state.
so if component supplied same props same output returned. clear.
he says
pure components... don’t rely on deep mutations in props or state, rendering performance can optimized shallow comparison in
shouldcomponentupdate()
hook
but means supply pure component same props object, difference located deeper inside said props object, , component render same different (albeit deep difference) props. means constraint not enforced.
is declaring component extends purecomponent
saying reactjs "i know doing. guarantee using immutable state. need perform shallow props comparisons in shouldcomponentupdate
"?
finally, purecomponent
s provide shallow shouldcomponentupdate
method default - presumably can overridden whatever want (even deep comparison)?
is declaring component extends purecomponent saying reactjs "i know doing. guarantee using immutable state. need perform shallow props comparisons in shouldcomponentupdate"?
yes
finally, purecomponents provide shallow shouldcomponentupdate method default - presumably can overridden whatever want (even deep comparison)?
you can override it. react try warn you not so. in case better inherit component
instead.
Comments
Post a Comment