JSX添加注释

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xutongbao/article/details/83023003
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

猜你喜欢

转载自blog.csdn.net/xutongbao/article/details/83023003