React+Redux 项目的标准文件夹结构是什么?

What's the standard folder structure of a React+Redux project?

React+Redux 项目的标准文件夹结构是什么?

你把

放在哪里

当我看到 react-redux-socketio-chat 时,我觉得这可能太多了。是否标准?

没有关于如何构建 react+redux 应用程序的标准,但有一个共同的模式。这个简单的样板 simple-redux-boilerplate 是常用模式的一个很好的例子。

Eni Arinde 建议的结构与 Redux 文档中建议的结构一致。

您可能也会觉得这个提议很有趣: https://github.com/erikras/ducks-modular-redux

基本上,您通过将 action creator 和 reducer 捆绑在一起来制作模块。这确实很有意义,因为您会发现它们非常紧密地结合在一起。

我有一个样板,其中包含遵循鸭子风格的 React redux 基本设置。您可以在这里找到它:https://github.com/nlt2390/le-react-redux-duck

一般来说,文件夹结构是这样的 react redux file structure

  • 组件:反应组件
  • containers:组件使用 connect(Component)
  • 连接到 redux
  • :包含许多"components""containers"
  • layouts:包含"pages"&"routes"react-router 外面包裹了一些 html。
  • utils:包含在整个应用程序中使用的所有函数、常量,例如 convertStringToNumber()apiUrl
  • state: 包含"actions", "reducers", redux 存储中的数据,例如 { post: [], postDetails: {title: 'lorem' } }