Tuples populate actual values as inputs (#551)
This commit is contained in:
parent
6afd2ed5b6
commit
3f8b92c8ba
@ -22,7 +22,7 @@ export default class Hash extends React.PureComponent<Props> {
|
||||
length={32}
|
||||
name={name}
|
||||
onChange={onChange}
|
||||
size={isDisabled ? 'full' : 'medium'}
|
||||
size={isDisabled ? 'full' : 'large'}
|
||||
style={style}
|
||||
type={type}
|
||||
withLabel={withLabel}
|
||||
|
||||
@ -6,6 +6,7 @@ import { TypeDef } from '@polkadot/types/codec';
|
||||
import { Props, RawParam } from '../types';
|
||||
|
||||
import React from 'react';
|
||||
import { isUndefined } from '@polkadot/util';
|
||||
|
||||
import Bare from './Bare';
|
||||
import findComponent from './findComponent';
|
||||
@ -30,7 +31,7 @@ export default class Tuple extends React.PureComponent<Props, State> {
|
||||
};
|
||||
}
|
||||
|
||||
static getDerivedStateFromProps ({ type: { sub, type } }: Props, prevState: State): Partial<State> | null {
|
||||
static getDerivedStateFromProps ({ defaultValue, type: { sub, type } }: Props, prevState: State): Partial<State> | null {
|
||||
if (type === prevState.type) {
|
||||
return null;
|
||||
}
|
||||
@ -43,7 +44,11 @@ export default class Tuple extends React.PureComponent<Props, State> {
|
||||
Components: subTypes.map((type) => findComponent(type)),
|
||||
sub: subTypes.map(({ type }) => type),
|
||||
subTypes,
|
||||
type
|
||||
type,
|
||||
values: (defaultValue.value as Array<any>).map((value) => ({
|
||||
isValid: !isUndefined(value),
|
||||
value
|
||||
}))
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user