上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 20 下一页
摘要: import React, {useState,memo,useCallback,useMemo} from 'react'; import ReactDOM from 'react-dom'; let ChildComp = ({info,changeStr})=>{ console.log(11 阅读全文
posted @ 2020-10-22 15:50 国服第一李师师 阅读(365) 评论(0) 推荐(0)
摘要: function useContext(context){ console.log(context._currentValue) return context._currentValue; } let CounterContext = React.createContext(); function  阅读全文
posted @ 2020-10-21 20:08 国服第一李师师 阅读(196) 评论(0) 推荐(0)
摘要: 其实useReducer和useState有点相似,useState之前介绍过是useReducer的语法糖。 我们看两个code useEffect(() => { console.log(a) timerID.current = setInterval(()=>{ setCount(count  阅读全文
posted @ 2020-10-21 19:41 国服第一李师师 阅读(249) 评论(0) 推荐(0)
摘要: 这个图是我 之前犯了错误好久没注意,今天终于忍不住去查了下,原来就是因为state里面的一个数据人家开始是{},而我去给人家赋值成了数组 阅读全文
posted @ 2020-10-21 13:59 国服第一李师师 阅读(1566) 评论(0) 推荐(1)
摘要: useRef在网上看了好几篇博客+自己理解 let lastRef function useRef(value){ lastRef = lastRef || {current:value} return lastRef } 我们利用这个useRef可以绑定dom,还可以自定义hook,这里我主要讲下 阅读全文
posted @ 2020-10-20 21:10 国服第一李师师 阅读(486) 评论(0) 推荐(0)
摘要: 要知道useReducer是useState的语法糖 function useState (initial){ return useReducer(null,initial) } function useReducer(reducer,initialState){ hookStates[hookIn 阅读全文
posted @ 2020-10-20 17:36 国服第一李师师 阅读(369) 评论(0) 推荐(0)
摘要: 接着上一篇文章,React.createContext() 给这个东西赋值比如叫 let CounterContext = React.createContext(); 那么CounterContext它里面肯定是有provider,consumer的, 而useContext做的就是把Counte 阅读全文
posted @ 2020-09-24 20:53 国服第一李师师 阅读(401) 评论(0) 推荐(0)
摘要: import React from 'react' import ReactDOM from "react-dom" const {Provider,Consumer} = React.createContext() class ContextDemo extends React.Component 阅读全文
posted @ 2020-09-20 18:33 国服第一李师师 阅读(1230) 评论(0) 推荐(0)
摘要: import React from 'react'; import ReactDOM from 'react-dom'; let hooksIndex = 0 const hooksState = [] const useState = (initialValue)=>{ hooksState[ho 阅读全文
posted @ 2020-09-15 09:04 国服第一李师师 阅读(190) 评论(0) 推荐(0)
摘要: function curring(fn,args=[]){ let l = fn.length return function(...arg){ let newArgs = [...arg,...args] if(newArgs.length == l){ return fn(...newArgs) 阅读全文
posted @ 2020-09-06 13:13 国服第一李师师 阅读(125) 评论(0) 推荐(0)
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 20 下一页