Indeterminate checkbox in React JSX

前端 未结 7 1616
旧时难觅i
旧时难觅i 2021-01-01 17:00

How do I render an indeterminate checkbox via JSX?

Here\'s what I\'ve tried:

function ICB({what}) {
  return 

        
7条回答
  •  感情败类
    2021-01-01 17:11

    You can use the componentDidMount step (which is invoked after the initial rendering) to set that property:

    componentDidMount() {
        React.findDOMNode(this).indeterminate = this.props.state === "indeterminate";
    }
    

    If you want that property to be updated with subsequent renders, do the same thing in componentDidUpdate also.

提交回复
热议问题