【问题标题】:How to check react component instance如何检查反应组件实例
【发布时间】:2023-03-03 05:23:25
【问题描述】:

我有一些代码:

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版本

【问题讨论】:

    标签: node.js react-router


    【解决方案1】:
    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
                        });
    
                    });
            });
    }
    

    【讨论】:

      猜你喜欢
      • 2017-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-02
      • 1970-01-01
      • 2017-04-17
      • 1970-01-01
      相关资源
      最近更新 更多