diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-04-28 23:28:27 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-04-28 23:28:27 +0200 |
commit | d6bf24902a34f2094363121c8d9f4d54db6f7b6c (patch) | |
tree | 0794956ebdf91a2fbea16baa0e8aa559f45c5d06 /src/components.ts | |
parent | ce97b1076b7e4a53b84d3fd34bf2047580ddeb22 (diff) | |
download | wallet-core-d6bf24902a34f2094363121c8d9f4d54db6f7b6c.tar.xz |
implement new reserve creation dialog and auditor management
Diffstat (limited to 'src/components.ts')
-rw-r--r-- | src/components.ts | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/components.ts b/src/components.ts index 4ed746f67..569810f3a 100644 --- a/src/components.ts +++ b/src/components.ts @@ -33,12 +33,23 @@ export interface StateHolder<T> { * but has multiple state holders. */ export abstract class ImplicitStateComponent<PropType> extends React.Component<PropType, any> { + _implicit = {needsUpdate: false, didMount: false}; + componentDidMount() { + this._implicit.didMount = true; + if (this._implicit.needsUpdate) { + this.setState({} as any); + } + } makeState<StateType>(initial: StateType): StateHolder<StateType> { let state: StateType = initial; return (s?: StateType): StateType => { if (s !== undefined) { state = s; - this.setState({} as any); + if (this._implicit.didMount) { + this.setState({} as any); + } else { + this._implicit.needsUpdate = true; + } } return state; }; |