Xaip
@Xaip

Как правильно наследовать роуты в React?

Как правильно настроить наследование роутов, так что бы при переходе по адресу /user/message или /user/cart, он рендерил компнонент, а не выдавал ошибку:
Refused to execute script from 'http://127.0.0.1:3000/user/bundle.min.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

Вот так у меня выглядит index.js.
<BrowserRouter>
                <Router>
                    <div className="none-container">
                        <Header/>
                        <Switch>
                            <Route exact path="/" component={App}/>
                            <Route path="/user" component={Authentication}/>                               //Точка входа в профиль
                            <Route path="/:id" component={Detail}/>
                        </Switch>
                    </div>
                </Router>
            </BrowserRouter>

Вот сам компонент Authentication
<Profile profile={profile} auth={auth}/>
                    <Switch>
                        <Route path="/user/cart"
                               render={() => <Cart profile={profile} auth={auth} AppActions={this.props.AppActions}
                                                   getCart={getCart}/>}/>
                        <Route path="/user/message"
                               render={() => <Message message={message} auth={auth}
                                                      AppActions={this.props.AppActions} dispatch={this.props.dispatch} />}/>
                    </Switch>

Роут /user нормально рендерится при обновлении, а роут внутри второго свитча /user/message нет
  • Вопрос задан
  • 125 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы