reactjs - Low performance in React Native with Redux -
i have discovered issues performance in react native app. seems caused react-redux bundle.
as can see in video
there significant delay between action dispatching , view rendering. on real devices looks worse. there no api calls in example. simple actions dispatching , state changes. on other hand facebook flux implementation , simple call of setstate work more faster.
any ideas how improve app performance?
i using react: v15.2.1, react-native: v0.29.2, react-redux: v4.4.5,
view
import { bindactioncreators } 'redux'; import { connect } 'react-redux'; import {map} 'immutable'; import * testactions '../reducers/test/testactions'; import {actions} 'react-native-router-flux'; const actions = [ testactions ]; function mapstatetoprops(state) { return { ...state }; } function mapdispatchtoprops(dispatch) { const creators = map() .merge(...actions) .filter(value => typeof value === 'function') .toobject(); return { actions: bindactioncreators(creators, dispatch), dispatch }; } ........ <view style={styles.box}> {price_filters.map(filter =>{ let price_cont_style = {}; let price_text_style = {}; if (filter.id == price_filters[3].id){ price_cont_style.marginright = 0; } if (filter.id == this.props.test.price){ price_cont_style.backgroundcolor = 'black'; price_text_style.color = 'white'; } return( <touchableopacity key={filter.id} style={[styles.price_cont, price_cont_style]} onpress={()=>this.props.actions.setprice(filter.id)}> <text style={[styles.price_text, price_text_style]}> {filter.label} </text> </touchableopacity> ); })} </view> ...... export default connect(mapstatetoprops, mapdispatchtoprops)(performancetest);
actions
const { test_set_price, } = require('../../lib/constants').default; export function setprice(filter) { return { type: test_set_price, payload: filter }; }
reducer
const { test_set_price, } = require('../../lib/constants').default; const initialstate = require('./testinitialstate').default; export default function authreducer(state = initialstate, action) { switch (action.type) { case test_set_price: if (state.price!=action.payload){ return {price:action.payload} } else{ return state; } } return state; }
i've noticed in video, have redux-logger enabled, flux , setstate not log console.
it might console.log causes performance drop. there known issue, here explanation.
try turn off console logging , see how affects performance.
Comments
Post a Comment