reactjs - Redirecting with react router -


i have following route config:

const route = {     path: 'services',      getcomponent(nextstate, callback) {         require.ensure([], (require) => {             callback(null, require('./components/services').default)         })     },     //getindexroute(partialnextstate, callback) {     //    require.ensure([], (require) => {     //        callback(null, {component: require('./components/consulting').default})     //    })     //},     childroutes: [         {             path: 'consulting',             getcomponent(nextstate, callback) {                 require.ensure([], (require) => {                     callback(null, require('./components/consulting').default)                 })             }         }     ],     indexredirect: {         //from: 'services',         to: 'consulting'     } }  export default route 

but when go /services receive error:

typeerror: element null

when used getindexroute worked fine, wish rather redirect /services/consulting. error, considering know not component?

indexredirect isn't available in object notation, jsx component. if reproduce it's behaviour should use onenter hook redirection. more details described here.

so, should change:

indexredirect: {     //from: 'services',     to: 'consulting' } 

to:

indexroute: {      onenter: (nextstate, replace) => replace('/consulting')  } 

Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -