反応フォームを使用して単純なフォームを作成し、アイテムのリストをコンポーネントに渡したいと考えていSelect
ます。Select
コンポーネントはreact-form
ライブラリの一部です。
fooItems
に aを渡したいSelect
Select
コンポーネントに必要な構造
selectItems = [{
value: 1,
label: 'a',
}, {
value: 2,
label: 'b',
}]
fooItems
まず、Redux から受け取った配列をフィルタリングしたいmapStateToProps
fooItems = [{
id: 1,
name: 'a',
parent: 'P',
child: 'C'
}, {
id: 2,
name: 'b',
parent: 'P',
child: 'C'
}]
小道具をコンポーネントに渡しながら関数を実装しようとしています
render() => (
<Select
field = "foo"
id = "foo"
options = {
() => {
return this.props.fooItems.map(e => {
return {
label: e.name,
value: e.id
}
})
}
}
/>)
しかし、次のエラーが発生します
Uncaught TypeError: Cannot read property 'find' of undefined
at t.value (index.js:1)
The above error occurred in the <t> component:
in t (created by r)