forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🤖 Merge PR DefinitelyTyped#49276 [react-select] Added group support t…
…o `isValidNewOption` for CreatableProps by @mathieumg
- Loading branch information
Showing
3 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import * as React from 'react'; | ||
|
||
import CreatableSelect from 'react-select/creatable'; | ||
import { ColourOption, groupedOptions, FlavourOption } from '../data'; | ||
|
||
export default class CreatableGroup extends React.Component { | ||
handleIsValidNewOption = (inputValue: any, value: any, groups: any) => { | ||
for (const group of groups) { | ||
console.group(`Group: ${group.label}`); | ||
for (const option of group.options) { | ||
console.log(`Option: ${option.label}`); | ||
} | ||
console.groupEnd(); | ||
} | ||
|
||
return true; | ||
} | ||
render() { | ||
return ( | ||
<CreatableSelect<ColourOption | FlavourOption> | ||
isValidNewOption={this.handleIsValidNewOption} | ||
options={groupedOptions} | ||
/> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters