Skip to content

Latest commit

History

History
28 lines (22 loc) · 402 Bytes

File metadata and controls

28 lines (22 loc) · 402 Bytes

Context 两种方式

  1. childContentType
  2. createContext
importReactfrom'react'importPropTypesfrom'prop-types'const{ Provider, Consumer }=React.createContext('default')classParentextendsReact.Component{state={ChildContext: '123',newContext: '456',}getChildContext(){return{value: this.state.childContext}}render(){return(<>
)
}}