Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
251 views
in Technique[技术] by (71.8m points)

javascript - React Semantic UI Dropdown get name of current selection, pass to child component

In my React application I'm using Semantic UI's Dropdown components. When an option in the dropdown is selected (onClick) I want to be able to get the text value of the current dropdown selection and send that string to another component as a prop.

Below is what my render method in the component looks like as of right now. I image the Dropdown would have to have an onClick method execute that grabs the value of the selection just clicked, and then send that as a prop to the <CookbookSelection /> component adjacent to the dropdown.

render() {
    return (
        <div>
            <Dropdown
                id="thing"
                placeholder={this.props.defaultCookbook}
                fluid
                selection
                options={this.props.cookbookData}
                onChange={this.props.setCurrentCookbook}
            />
            <CookbookSelection />
        </div>
    );
}

Any help understanding how to do this? Thanks.

question from:https://stackoverflow.com/questions/65661581/react-semantic-ui-dropdown-get-name-of-current-selection-pass-to-child-componen

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...