由于 10 月份做的 React Native 项目没有使用到 Redux 等库,写了一段时间想深入学习 React,有个想法想做个 demo 练手下,那时候其实还没想好要做哪一个类型的,也看了些动漫的,小说阅读,聚合资源的开源项目。由于正好在学习开源的 Android 小说阅读器 -- 任阅,开始边学边做,已完成的功能列在下面。项目地址 在这里,如果有好的意见欢迎提 issue或pr。
.
├─actions #redux的action,业务逻辑
├─components #页面容器
│ └─common #公共目录
│ ├─component-module #封装的组件
│ ├─images #项目图片
│ │ └─icon
│ └─style #组件样式
├─modules #公用模块
│ ├─api #管理api请求类
│ └─constants #公共字段类
├─reducers #redux中的reducers,处理action发送的数据流
├─router #路由管理模块
├─store #redux中的store,联结reducers
└─template #存放html模版
.
项目的初始结构和说明已罗列如上。
下面对目录结构作以下说明
后面 9、10 两章开始运用上面学到的内容,做一个简单的项目。
参考所使用的库、编译打包的脚本以及 redux 代码。
这部分内容是后面在搭建项目整体结构的时候看的,对于 reducers、action、store 的内容比较深入,加深理解。
问题 | 1.x | 3.10 | 备注 | 参考 |
---|---|---|---|---|
webpack 2 cannot resolve empty extensions | extensions数组中不能出现空字符或者字符串 | resolve: {extensions: ['','.css']} | resolve: {extensions: ['.css']} | 参考1 |
Error: Chunk.entry was removed. Use hasRuntime() | "extract-text-webpack-plugin": "^1.10.0", | "extract-text-webpack-plugin": "^2.1.2", | 版本问题 | 参考1 |
Error: Breaking change: extract now only takes a single argument. Either an options object *or* the loader(s). | loader: ExtractTextPlugin.extract('style', ['css', 'autoprefixer']), | ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' }) | 新的版本只支持一个参数 | npm run dev 命令运行结果错误提示 |
找不到API Schema | modulesDirectories | modules | 属性名称变更 | npm run dist 命令运行结果错误提示 |
找不到OccurenceOrderPlugin | new webpack.optimize.OccurenceOrderPlugin(),newwebpack.HotModuleReplacementPlugin(),new webpack.NoErrorsPlugin(),new webpack.optimize.UglifyJsPlugin() | new webpack.HotModuleReplacementPlugin(),new webpack.optimize.UglifyJsPlugin() | 移除了OccurenceOrderPlugin 和 NoErrorsPlugin | 参考1 |
react-router(2.x)与react-router(4.x)的还是不同的,当然主要是写法上,所以没更新到4.0
另外, 发布打包时使用nginx等应用服务器托管的时候需要配置下,所用路由走index.html文件,不然路由会被拦截。