Tuples populate actual values as inputs (#551)

This commit is contained in:
Jaco Greeff 2018-12-31 16:23:23 +01:00 committed by GitHub
parent 6afd2ed5b6
commit 3f8b92c8ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -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}

View File

@ -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
}))
};
}