# 越级传值 - Context API

# 基本用法

# 创建上下文

let themeContext = React.createContext({});
1

# Provider

<themeContext.Provider value={this.state.theme}>
  <ToolBar />
</themeContext.Provider>
1
2
3

# Consumer

<themeContext.Consumer>
  {value => <div className={`bordered ${value}`}>{value}</div>}
</themeContext.Consumer>
1
2
3