React select with Material Design wrote in ES2015(ES6)
npm install react-material-select---
$ npm i react-material-select --save
---
http://react-material-select.netlify.com/
---
parameter | description | is required
:-: | :-: | :-:
onChange | callback function (function) | no
defaultValue | start value. One of dataValue keys. Default: null (string) | no
label | label for select. Default: null (string) | no
resetLabel | label for reset select value. Default: 'No value' (string) it also can be boolean value "false" | no
parameter | description | is required
:-: | :-: | :-:
dataValue | selected value (string) | yes
method | description
:-: | :-:
this.getValue() | get selected value
this.getLabel() | get selected label
this.handleToggleSelect() | open / close selector
this.handleResetSelect() | reset selector value and label
this.handleSetSelect(label, value) | set specified value and label to selector
this.getOptions() | get all available options as an array of objects
It should looks like below:
``
import React, {Component} from 'react'
import ReactMaterialSelect from 'react-material-select'
import 'react-material-select/lib/css/reactMaterialSelect.css'
class Example extends Component {
render() {
return (
...
)
}
}
`
`
import React, {Component} from 'react'
import ReactMaterialSelect from 'react-material-select'
import 'react-material-select/lib/css/reactMaterialSelect.css'
getValue() {
this.setState({
selected1: {
value: this.refs.firstselect.getValue(),
label: this.refs.firstselect.getLabel(),
},
})
}
class Example extends Component {
render() {
return (
...
)
}
}
`
`
import React, {Component} from 'react'
import ReactMaterialSelect from 'react-material-select'
import 'react-material-select/lib/css/reactMaterialSelect.css'
constructor() {
super()
this.state = {
object: {},
}
this.callbackFunction = this.callbackFunction.bind(this)
}
callbackFunction(selected) {
this.setState({object: selected})
}
class Example extends Component {
render() {
return (
...
)
}
}
`
---
To remember how to do it ;)
1. change version of the package
2. npm run compilenpm run build
3. npm publish`
4. git commit
5.