无法从react-router-modal访问历史记录

时间:2019-03-12 14:50:35

标签: javascript reactjs react-router react-router-dom reactstrap

您好,我在为最后使用的组件设置'react-router-modal'parentPath时遇到问题

ModalRoute和ModalContainer是 react-router-modal

App.js

class App extends Component {
  render() {
    return (
      <main>
        <Navbar />
        <BrowserRouter>
          <div>
            <Switch>
              <Route path="/main" component={ContentDefault} />
              <Route path="/search" component={SearchScreen} />
              <ModalRoute
                path="/register"
                parentPath="/"
                component={RegisterScreen}
              />
              <Route path="/contact" component={ContentDefault} />
              <Route component={ContentDefault} />
            </Switch>
            <ModalContainer />
          </div>
        </BrowserRouter>
        <Footer />
      </main>
    );
  }
}

export default App;

SearchScreen.jsx

import React, { Component } from "react";
import { withRouter } from "react-router-dom";

class SearchScreen extends Component {
  render() {
    return (
      <main>
        <h1>SearchScreen</h1>
      </main>
    );
  }
}

export default withRouter(SearchScreen);

例如,我在mainScreen上,然后移至SearchScreen,然后从navbar打开模式。我需要模态返回到SearchScreen

0 个答案:

没有答案