返回博主主页
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 27 下一页
摘要: export type Dispatcher = { useState<S>(initialState: (() => S) | S): [S, Dispatch<BasicStateAction<S>>], useReducer<S, I, A>( reducer: (S, A) => S, in 阅读全文
posted @ 2022-02-13 21:19 懒惰的星期六 阅读(63) 评论(0) 推荐(0) 编辑
摘要: 笔记: 1. mapStateToProps中,使用state._time.xxx的原因是,_time是reducer函数的名字。 // 这是我们的 select 函数, 它会把我们需要在属性 (prop) 中对我们的组件暴露的数据从 state 中抽离出来 const mapStateToProp 阅读全文
posted @ 2022-02-13 14:01 懒惰的星期六 阅读(82) 评论(0) 推荐(0) 编辑
摘要: var a = (x,y,z)=>{ } console.log(a.length) // 3 //legnth:返回函数形参的个数,不包括rest参数的和赋值的形参 let f = (a,b,c,d,g,f=10,...e) => console.log(f.length);//5 f() 阅读全文
posted @ 2022-02-12 20:40 懒惰的星期六 阅读(40) 评论(0) 推荐(0) 编辑
摘要: 原生js实现检测对象变化。 通过把属性转换为访问器属性,实现监听。 对象属性的更改通过设置 get, set。 数组类型元素的更改通过在prototype重载操作数据的方法:slice、push、shift…… const OP = Object.prototype; const types = { 阅读全文
posted @ 2022-02-12 18:01 懒惰的星期六 阅读(6644) 评论(0) 推荐(0) 编辑
摘要: Context Context 提供了一个无需为每层组件手动添加 props,就能在组件树间进行数据传递的方法。 在一个典型的 React 应用中,数据是通过 props 属性自上而下(由父及子)进行传递的,但此种用法对于某些类型的属性而言是极其繁琐的(例如:地区偏好,UI 主题),这些属性是应用程 阅读全文
posted @ 2022-02-12 16:35 懒惰的星期六 阅读(85) 评论(0) 推荐(0) 编辑
摘要: 在高阶组件中转发 refs function logProps(WrappedComponent) { class LogProps extends React.Component { componentDidUpdate(prevProps) { console.log('old props:', 阅读全文
posted @ 2022-02-12 16:00 懒惰的星期六 阅读(86) 评论(0) 推荐(0) 编辑
摘要: Refs 与函数组件 默认情况下,你不能在函数组件上使用 ref 属性,因为它们没有实例: function MyFunctionComponent() { return <input />; } class Parent extends React.Component { constructor( 阅读全文
posted @ 2022-02-12 15:37 懒惰的星期六 阅读(226) 评论(0) 推荐(0) 编辑
摘要: https://zh-hans.reactjs.org/docs/lifting-state-up.html 这样 多个子组件的值可以联动变化。 关键点: class ParentComponent extends React.Componnet{// ………… changeMyValue=(par 阅读全文
posted @ 2022-02-12 15:30 懒惰的星期六 阅读(54) 评论(0) 推荐(0) 编辑
摘要: https://zh-hans.reactjs.org/docs/render-props.html 术语 “render prop” 是指一种在 React 组件之间使用一个值为函数的 prop 共享代码的简单技术 具有 render prop 的组件接受一个返回 React 元素的函数,并在组件 阅读全文
posted @ 2022-02-12 15:02 懒惰的星期六 阅读(49) 评论(0) 推荐(0) 编辑
摘要: https://www.jianshu.com/p/a69ef7a71681 阅读全文
posted @ 2022-02-11 18:42 懒惰的星期六 阅读(21) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 27 下一页

Welcome to here

主页