From 92ee50a4a4c4a934c9f5051cd8fc74bf81f6ef4d Mon Sep 17 00:00:00 2001 From: orangemug Date: Wed, 16 Oct 2019 07:36:30 +0100 Subject: [PATCH] Added default support to --- src/components/inputs/ArrayInput.jsx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/components/inputs/ArrayInput.jsx b/src/components/inputs/ArrayInput.jsx index 69a01d5..5a8a4f5 100644 --- a/src/components/inputs/ArrayInput.jsx +++ b/src/components/inputs/ArrayInput.jsx @@ -12,29 +12,32 @@ class ArrayInput extends React.Component { onChange: PropTypes.func, } + static defaultProps = { + value: [], + default: [], + } + changeValue(idx, newValue) { console.log(idx, newValue) - const values = this.values.slice(0) + const values = this.props.value.slice(0) values[idx] = newValue this.props.onChange(values) } - get values() { - return this.props.value || this.props.default || [] - } - render() { - const inputs = this.values.map((v, i) => { + const inputs = Array(this.props.length).fill(null).map((_, i) => { if(this.props.type === 'number') { return } else { return }