小编Fra*_*sso的帖子

如何获取新数据以响应Redact的React Router更改?

我正在使用Redux,redux-router和reactjs.

我正在尝试创建一个应用程序来获取路由更改的信息,所以,我有类似的东西:

<Route path="/" component={App}>
    <Route path="artist" component={ArtistApp} />
    <Route path="artist/:artistId" component={ArtistApp} />
</Route>
Run Code Online (Sandbox Code Playgroud)

当有人进入时,artist/<artistId>我想搜索艺术家,然后呈现信息.问题是,这是最好的方法吗?

我找到了一些关于它的答案,使用RxJS或尝试使用中间件来管理请求.现在,我的问题是,这真的是必要的还是仅仅是一种保持架构反应不可知的方法?我可以从react componentDidMount()和componentDidUpdate()获取我需要的信息吗?现在我通过触发请求信息的函数中的动作来执行此操作,并在信息到达时重新呈现组件.该组件有一些属性让我知道:

{
    isFetching: true,
    entity : {}
}
Run Code Online (Sandbox Code Playgroud)

谢谢!

javascript reactjs react-router redux

48
推荐指数
2
解决办法
2万
查看次数

如何构建Redux组件/容器

我正在使用redux而且我不确定如何组织我的组件,我认为最好将它们保存在文件夹中,主要组件的名称作为文件夹的名称和内部的所有内部组件:

components
  Common/   things like links, header titles, etc
  Form/     buttons, inputs, etc
  Player/   all small components forming the player
    index.js  this one is the top layout component
    playBtn.js
    artistName.js
    songName.js
  Episode/  another component

然后,在容器文件夹中,我每页只有一个容器,这是我实际连接到Redux的唯一容器:

containers/
  HomePageApp.js
  EpisodePageApp.js
  ...

然后每个顶部组件的操作是一个,而不是每页一个,所以在我连接到Redux的页面容器中,我传递了该页面中使用的组件的所有操作.例如:

actions/
  Player.js
  Episode.js
  ...

我这样做了吗?我没有找到关于谷歌搜索的很多信息,我发现我认为它们仅限于小项目.

谢谢!

javascript reactjs reactjs-flux redux

43
推荐指数
2
解决办法
2万
查看次数

标签 统计

javascript ×2

reactjs ×2

redux ×2

react-router ×1

reactjs-flux ×1