import React, { Component } from 'react';
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import ThemeSwitch from './ThemeSwitch'

class Header extends Component {
  static propTypes = {
    themeColor: PropTypes.string
  }

  render () {
    return (
      <div>
        {/* 在一个组件的子元素位置使用注释要 */}
        <h1 style={{ color: this.props.themeColor }}>xutongbao</h1>
        <ThemeSwitch /* 在组件标签上的注释 */ />
      </div>
    )
  }
}

const mapStateToProps = (state) => {
  return {
    themeColor: state.themeColor
  }
}
Header = connect(mapStateToProps, null)(Header)

export default Header

 

相关文章:

  • 2021-11-29
  • 2022-12-23
  • 2022-12-23
  • 2021-10-22
  • 2021-12-18
  • 2021-11-29
  • 2022-01-07
猜你喜欢
  • 2021-10-29
  • 2021-12-08
  • 2021-12-22
  • 2021-05-11
  • 2022-02-07
  • 2022-02-07
  • 2021-06-26
相关资源
相似解决方案