我已经为这个问题苦苦挣扎了好几个小时,似乎无法找出问题所在。我尝试将所有内容包装在div中以使其成为一个组件,将我的提供程序放在AppRouter的顶级包装上,什么也没有。
class AppRouter extends Component {
render() {
return (
<ApolloProvider client={client}>
<Router>
<React.Fragment>
<Navigation brand="visua" loggedIn={SHOW} routes={routes}/>
{[...routes].map((route) => <Route path={route.path} component={route.component}/>)}</React.Fragment>
</Router>
</ApolloProvider>
)
}
}
export default AppRouter;
Index.js
import React from 'react';
import ReactDOM from 'react-dom';
import AppRouter from './router.jsx'
ReactDOM.render(<AppRouter/>, document.getElementById('rootp'));