reactjs - Which is better performance: to import once and pass as props to <Row/> or import within each <Row/> component? -
i guess general question be, require more handling pass something
props <child something={something}/>
or import something
within <child/>
.
so example, have:
import { basestyle } '../styles/common.js'; <flatlist data={this.state.datasource} renderitem={this.renderitem} /> renderitem() { return ( <customrow basestyle={basestyle} /> ) }
or better import basestyle
within <customrow/>
component?
i assume @ least <list/>
component, react/rn smart enough cache imports <row/>
components until has finished rendering every <row/>
.
does have theories this?
so quite simple test out. did set variable
var time = date.now();
outside of class above import
statements , console logged time
in componentdidmount()
. showed same time registered first date.now()
assignment var time
, every time component re-rendered. think it's safe assume behavior if it's possible import constant, instead of passing down props components recheck due potential updates.
Comments
Post a Comment