-
生命周期啊
查看全部 -
state改變
查看全部 -
實(shí)例 - 名片
查看全部 -
Props屬性
查看全部 -
JSX語(yǔ)法2
查看全部 -
JSX語(yǔ)法
查看全部 -
準(zhǔn)備開(kāi)發(fā)環(huán)境
查看全部 -
為什么使用它
查看全部 -
React是什么
查看全部 -
//創(chuàng)建context import?React?form?"react" const?context?=?React.createContext() export?default?context;
使用context
import?ThemeContext?from?"./theme-context.js" render(){ ????<ThemeContext.Provider?value={...}> ????????<component/> ????????... ????</ThemeContext.Provider> }
import?ThemeContext?from?"./theme-context.js" render()?{ ????<ThemeContext.Consumer> ????????{ ????????????theme?=>{ ????????????????console.log(theme) ????????????} ????????} ????</ThemeContext.Consumer> }
查看全部 -
Context 的用途:
設(shè)計(jì)目的是共享那些對(duì)于組件來(lái)說(shuō)全局的數(shù)據(jù)
不要僅僅為了避免在幾個(gè)層級(jí)下的組件傳遞props而使用context
查看全部 -
期待查看全部
-
1,jsx是一種語(yǔ)法糖,替代React.createElement()方法。
2,這個(gè)方法返回的是ReactElement對(duì)象
查看全部 -
生命周期-圖
查看全部 -
constructor(props) {
????super(props)
????this.state = {
????????comments: ['this is my first reply']
????}
}
查看全部
舉報(bào)