如何检查反应组件实例

时间:2016-02-26 09:48:29

标签: node.js react-router

我有一些代码:

export default function universalRouter(location, history, store) {

return new Promise((resolve, reject) => {
        Router.run(routes, location, [createTransitionHook(store)], (error, initialState, transition) => {                    
                const component = (<Provider store={store}
                    key = 'provider' > {() => < Router{...initialState}  
                    children = {routes}/>} < /Provider>);
                    return resolve({
                        component,
                        isRedirect: false
                    });

                });
        });
}

和一些路线:

<Route>
   ...
   <Route path='*' component={NotFound}/>
</Route>

如何检入此代码组件解析NotFound,也许是instanceof Notfound,react-router v1.0.0的版本

1 个答案:

答案 0 :(得分:0)

export default function universalRouter(location, history, store) {

return new Promise((resolve, reject) => {
        Router.run(routes, location, [createTransitionHook(store)], (error, initialState, transition) => {                    
                const component = (<Provider store={store}
                    key = 'provider' > {() => < Router{...initialState}  
                    children = {routes}/>} < /Provider>);
                    return resolve({
                        component,
                        isRedirect: true
                    });

                });
        });
}