08 2020 档案

摘要:https://reactjs.org/docs/context.html官网链接:React官⽅⽂档中,Context被归类为⾼级部分(Advanced), 属于React的⾼级API,但官⽅并不建议在稳定版的App中使⽤ Context。封装Appcontent.js方便其他组件调用: impo 阅读全文
posted @ 2020-08-31 23:23 雪糕战士 阅读(303) 评论(0) 推荐(0)
摘要:官网地址:https://zh-hans.reactjs.org/docs/react-component.html#static-getderivedstatefrompropsV17可能会废弃的三个⽣命周期函数⽤getDerivedStateFromProps 替代,⽬前使⽤的话加上UNSAFE 阅读全文
posted @ 2020-08-31 22:22 雪糕战士 阅读(133) 评论(0) 推荐(0)
摘要:父传子: 3 父组件代码: 4 import React from 'react'; 5 import User from './pages/User' 6 import Search from './pages/Search' 7 8 function App() { 9 10 const con 阅读全文
posted @ 2020-08-30 23:33 雪糕战士 阅读(363) 评论(0) 推荐(0)
摘要:1 import React,{ useState,useEffect } from 'react' 2 function User(){ 3 const [date,setDate] = useState(new Date()); 4 const [date2,setDate2] = useSta 阅读全文
posted @ 2020-08-28 23:59 雪糕战士 阅读(271) 评论(0) 推荐(0)
摘要:解决异步: 1、nextState(推荐) import React from 'react' class Home extends React.Component{ constructor(props){ super(props); this.state = { data :0 } } compo 阅读全文
posted @ 2020-08-26 00:29 雪糕战士 阅读(1537) 评论(0) 推荐(0)
摘要:1、下载git 2、使用git打开github文件 3、在git中执行npm install,现在时间有点长耐心点即可 阅读全文
posted @ 2020-08-10 23:50 雪糕战士 阅读(1485) 评论(0) 推荐(0)