ytxbnahn / blog

my blog
1 stars 0 forks source link

react 学习笔记 #6

Open ytxbnahn opened 6 years ago

ytxbnahn commented 6 years ago

build之后registerServiceWorker问题

具体原因不明但是问题解决,服务器需要https才可以 目前解决:删除 参考链接https://stackoverflow.com/questions/34290337/serviceworker-registration-failed-domexception-only-secure-origins-are-allowed

build router错误

目前解决: import { HashRouter as Router, Route } from 'react-router-dom import createHistory from 'history/createHashHistory const history = createHistory() `const RouteConfig = (

) link :index` 参考链接https://www.cnblogs.com/fengnovo/p/6951533.html

TypeError: middleware is not a function

在使用redux的异步操作时,参考教程http://cn.redux.js.org/docs/advanced/ExampleRedditAPI.html 但在运行时报上述错误,最终解决参考https://github.com/gaearon/redux-thunk/issues/35 具体原因:不详 中间件原理不懂

less使用

参考链接:https://ant.design/docs/react/use-with-create-react-app-cn 补充: 需加载npm install less --sava --dev

link 跳转

无法再router控件外添加

redux使用问题

在render中不小心调用了 action中的方法 进入了无限循环 理解: 渲染页面,触发方法,方法介绍渲染页面进入循环

this.setState异步问题

解决:this.setState({ state: data }, () => { console.log('回调') }); 参考链接https://segmentfault.com/a/1190000008051628

ios react的click问题

参考链接https://github.com/JakeSidSmith/react-fastclick

react的components建立索引

写法 export { default as Swiper } from './swiper/index'; export { default as ShareMask } from './ShareMask/index';

ytxbnahn commented 5 years ago

在使用新的布局方式vw之后引入了cssnano, 导致keyframes的名字变成了a,组件之间发生了冲突 解决方案 cssnano({ preset: "advanced", autoprefixer: false, reduceIdents: false, "postcss-zindex": false }) 参考链接

ytxbnahn commented 5 years ago

react 优化方案

memoize-one 参考链接

ytxbnahn commented 5 years ago

react-router

在使用Link是出现错误 Invariant Violation: React.Children.only expected to receive a single React element child.

解决

<Link to="/home">
        <div>hello</div>
</Link>

参考

ytxbnahn commented 5 years ago

react-virtualized

长列表渲染优化方案

ytxbnahn commented 5 years ago

react-loadable

组件异步加载方案