📌  相关文章
📜  类组件使用状态做出反应 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:09.704000             🧑  作者: Mango

代码示例1
import React, {Component} from 'react';
import './App.css';
import IconBar from './components/icon-bar';
import Events from './components/events';

class App() extends Component {
  constructor(props) {
        super(props)
        this.state = {
            mode: null
        }
        this.updateMode = this.updateMode.bind(this);
    }

  updateMode = (newMode) => {

      this.setState({mode: newMode});
  }


  return (
    

ENAKS

{this.state.mode}
); } export default App; Add this to your knowledge