🐛 Améliore la performance du select

pull/51/head
Laurent Bossavit 2017-10-01 15:32:54 +02:00
parent fe819e3dc4
commit ad33bd4115
2 changed files with 39083 additions and 39086 deletions

File diff suppressed because it is too large Load Diff

View File

@ -10,14 +10,12 @@ import './Select.css'
@FormDecorator('select')
export default class Select extends Component {
state = {
data: null,
filterOptions: null
data: null
}
componentDidMount(){
import(/* webpackChunkName: "communescsv" */ 'Règles/communes.csv')
.then(module => this.setState({
data: module,
filterOptions: createFilterOptions({ options: module, labelKey: 'Nom_commune', valueKey: 'Nom_commune' })
}))
.catch(error => 'An error occurred while loading the component')
}
@ -30,7 +28,6 @@ export default class Select extends Component {
} = this.props,
submitOnChange =
option => {
console.log('option', option)
onChange(option.Nom_commune)
submit()
}
@ -43,11 +40,11 @@ export default class Select extends Component {
<VirtualizedSelect
options={this.state.data}
onChange={submitOnChange}
ignoreAccents={false}
labelKey="Nom_commune"
valueKey="Nom_commune"
placeholder="Entrez le nom de commune"
noResultsText="Nous n'avons trouvé aucune commune"
filterOptions={this.state.filterOptions}
/>
</div>
)