[react] contextType是什么?它有什么用?
生活随笔
收集整理的這篇文章主要介紹了
[react] contextType是什么?它有什么用?
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
[react] contextType是什么?它有什么用?
定義當前組件要使用哪一個context
const MyContext = React.createContext(defaultValue);class MyClass extends React.Component {componentDidMount() {let value = this.context;/* perform a side-effect at mount using the value of MyContext */} } MyClass.contextType = MyContext;個人簡介
我是歌謠,歡迎和大家一起交流前后端知識。放棄很容易,
但堅持一定很酷。歡迎大家一起討論
主目錄
與歌謠一起通關前端面試題
總結
以上是生活随笔為你收集整理的[react] contextType是什么?它有什么用?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PHP基础学习之数组使用要点
- 下一篇: lorawan服务器通信协议,LoRaW