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