
react
Prpr_Saber
这个作者很懒,什么都没留下…
展开
-
React | 解决Warning: Each child in an array or iterator should have a unique "key" prop.
遍历的时候要给iterator 加上key值原创 2018-10-14 14:29:04 · 7446 阅读 · 0 评论 -
React16 | create-react-app配置less
_____ 最新版cra2.1.8往下看________先暴露出webpackConfignpm run eject安装less和less-loadernpm install less-loader less --save-dev打开webpack.config.dev.js { test: /\.less$/, ...原创 2019-03-30 12:49:49 · 810 阅读 · 0 评论 -
Rollup.js | 解决打包react项目报错ReferenceError: process is not defined
打开bundle.js定位报错: process对象是nodejs的环境变量,浏览器端是没有的。解决办法,在打包后的bundle.js里var一个process对象,例如var process = { env: { NODE_ENV: 'production' }}但是每次重新构建bundle.js后,又要重新添加,所以可以在rollup.config.js...原创 2019-01-26 22:05:57 · 17635 阅读 · 1 评论 -
React-bootstrap | 导入CSS报错Module not found: Can't resolve 'bootstrap/dist/css/bootstrap-theme.css'
检查package.json里的bootstrap是否是4.0或以上版本,如果是,则回退到3.0版本npm install bootstrap@3原创 2018-12-19 11:10:41 · 6642 阅读 · 3 评论 -
React-bootstrap | 解决Failed prop type: The prop `id` is required to make `Tabs` accessible for
<Tabs id="default" activeKey={this.props.current} onSelect={selectedKey => this.props.turnContext(Number(selectedKey))} > <Tab even...原创 2018-12-18 22:37:30 · 4266 阅读 · 0 评论 -
React | 关闭tslint约束
tslint.json中添加: "defaultSeverity": "none"告别烦恼(注意要重新npm start才会生效)原创 2018-12-02 19:49:17 · 7882 阅读 · 0 评论 -
React | 关闭sourceMap,减小包体积
打开文件webpack.config.prod.js,搜索“shouldUseSourceMap”,找到第一个结果,注释掉这一行,另起一行把它的值改为false const shouldUseSourceMap = false;原创 2018-10-14 20:42:04 · 3898 阅读 · 0 评论 -
React | build后打开index.html空白Failed to load resource: net::ERR_BLOCKED_BY_CLIENT
打开config/paths.js, 搜索“pathname”,在斜杠前加一个点原创 2018-10-14 20:15:35 · 3333 阅读 · 0 评论 -
React | 组件传值
1. 给子组件传值(构造函数)现在组件App给子组件Home传值,index.home//App.jsimport index from './common/json/data.json'class App extends Component { render() { return ( <div className="App"> ...原创 2018-10-14 16:07:12 · 212 阅读 · 0 评论 -
React | onClick回调函数传参
1. 箭头函数 包裹 <button onClick={() => { this.record(index) }} > </button> 2. bind绑定 <button onClick={this.record.bind(this, index)...原创 2018-10-14 14:36:59 · 2407 阅读 · 0 评论 -
React hooks-useEffect | 解决报错Warning...cancel all subscriptions and asynchronous tasks in a useEffect
const [isMobile, setIsMobile] = useState(false) useEffect(() => { window.onresize = () => { document.documentElement.clientWidth < 760 ? setIsMobile(true) : setIs...原创 2019-04-01 18:06:08 · 12097 阅读 · 0 评论