Skip to content

Instantly share code, notes, and snippets.

@pk936
Created May 18, 2017 06:07
Show Gist options
  • Save pk936/5832c517314267fc85fe1b1b28cc9185 to your computer and use it in GitHub Desktop.
Save pk936/5832c517314267fc85fe1b1b28cc9185 to your computer and use it in GitHub Desktop.
I want to access custom attribute in option tag in select
render(){
return (<select id="selectTemplate" ref={(input) => this.templateSelect = input}>
<option value="0" disabled selected>Select Template</option>
{(
()=>{
console.log("Templates", this.props.templates)
return this.props.templates.templates.data.map((template, index) => {
console.log("template.id::::::::::", template.id) // fine
return <option key={template.id} value={template.attributes.name}>{template.attributes.name}</option>
})
}
)()}
</select>)
}
somemethod(){
console.log(this.templateSelect.value) // value is shown
console.log(this.templateSelect.key) // undefine
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment