简体   繁体   中英

React: Can I match the div id with Props

I want to say,

componentDidMount() {
  if (x == y) {
    var x = ReactDOM.findDOMNode(this)
    var y = div.id
    $('#y').append(x)
  }
}

If the div id is equal to the name of the node, then append the node onto that div.

I am making a calendar application that and each event is a separate component that must be mapped onto a div with an id of 9:00AM, 10:00AM, 11:00AM, 12:00PM etc.

This.props.start_time returns

12:00AM

This is what worked:

  componentDidMount() {

    var x= ReactDOM.findDOMNode(this)
    var y = this.props.time
  $('#' + y).append(x)
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM