无法配置反应路由

时间:2017-01-03 08:19:15

标签: reactjs routes

你可以帮助我吗,我有下一条路线

export const routes = (
  <div>
    <Route path='/' component={App}>
      <IndexRoute component={Home} />
      <Route path='home' component={Home} />
      <Route path='categories' component={Category} />
      <Route path='books' component={Book}>
        <Route path='/categories/:category_id/books' component={Book} />
      </Route>
    </Route>
    <Route path='*' component={NotFound} />
  </div>
)

当我转到'/ categories /:category_id / books'路径时,它显示的是“书籍”标签,按类别显示书籍,但是当我点击链接'/ books'时,它仍会显示旧内容和组件“Book”not not重新加载。它应显示所有没有类别的书籍。书籍载入

class Book

componentDidMount() {
    const { category_id } = this.props.params;

    category_id ? this.props.loadBooksByCategory(category_id) : this.props.loadBooks();
  }

0 个答案:

没有答案