Want do you create opt groups in react-select v2? Use the below script to create opt groups in react-select v2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | render() { const options = [ { label: "Group 1", options: [ { label: "Group 1, option 1", value: "value_1" }, { label: "Group 1, option 2", value: "value_2" } ] }, { label: "A root option", value: "value_3" }, { label: "Another root option", value: "value_4" } ]; return <Select options={options} /> } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.