.tag(value: any): Component
The tag value used to identify this component. Typically a string or number. Must match the type of the Picker’s selection value.
Support
Usage
Picker items
Each item in a Picker must have a .tag() that corresponds to the selection value.
const body = () => {
const [size, setSize] = useState("m")
return Picker("Size", { value: size, setValue: setSize }, [
Text("Small").tag("s"),
Text("Medium").tag("m"),
Text("Large").tag("l"),
])
}
const body = () => {
const [rating, setRating] = useState(3)
return Picker("Rating", { value: rating, setValue: setRating }, [
Text("1 Star").tag(1),
Text("2 Stars").tag(2),
Text("3 Stars").tag(3),
Text("4 Stars").tag(4),
Text("5 Stars").tag(5),
]).pickerStyle("wheel")
}
Notes
- The
.tag() value must match the type used in the Picker’s value and setValue props.
- Tags are primarily used with Picker components to associate each option with a selection value.