How to use radio buttons in ReactJS?

前端 未结 10 2160
再見小時候
再見小時候 2020-11-27 10:05

I am new to ReactJS, sorry if this sounds off. I have a component that creates several table rows according to the received data.

Each cell within the column has a

10条回答
  •  半阙折子戏
    2020-11-27 10:17

    Clicking a radio button should trigger an event that either:

    1. calls setState, if you only want the selection knowledge to be local, or
    2. calls a callback that has been passed in from above self.props.selectionChanged(...)

    In the first case, the change is state will trigger a re-render and you can do
    chosen site name {this.state.chosenSiteName}

    in the second case, the source of the callback will update things to ensure that down the line, your SearchResult instance will have chosenSiteName and chosenAddress set in it's props.

提交回复
热议问题