aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/components
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-10-19 07:04:30 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-10-19 07:04:51 +0800
commitad6dc8e891059f00f2ddda1884bbc78c1e47ea24 (patch)
tree17e06dedb3dab0617586fb1ee585466266ad577d /packages/instant/src/components
parent44635f34f0df4da935ed4793566995873aac5055 (diff)
downloaddexon-sol-tools-ad6dc8e891059f00f2ddda1884bbc78c1e47ea24.tar
dexon-sol-tools-ad6dc8e891059f00f2ddda1884bbc78c1e47ea24.tar.gz
dexon-sol-tools-ad6dc8e891059f00f2ddda1884bbc78c1e47ea24.tar.bz2
dexon-sol-tools-ad6dc8e891059f00f2ddda1884bbc78c1e47ea24.tar.lz
dexon-sol-tools-ad6dc8e891059f00f2ddda1884bbc78c1e47ea24.tar.xz
dexon-sol-tools-ad6dc8e891059f00f2ddda1884bbc78c1e47ea24.tar.zst
dexon-sol-tools-ad6dc8e891059f00f2ddda1884bbc78c1e47ea24.zip
fix: refactor ZeroExInstant state creation logic and fix bug
Diffstat (limited to 'packages/instant/src/components')
-rw-r--r--packages/instant/src/components/zero_ex_instant.tsx9
1 files changed, 6 insertions, 3 deletions
diff --git a/packages/instant/src/components/zero_ex_instant.tsx b/packages/instant/src/components/zero_ex_instant.tsx
index 5b75a7556..a67c0f412 100644
--- a/packages/instant/src/components/zero_ex_instant.tsx
+++ b/packages/instant/src/components/zero_ex_instant.tsx
@@ -29,8 +29,7 @@ export class ZeroExInstant extends React.Component<ZeroExInstantProps> {
additionalAssetMetaDataMap: {},
};
public store: Store;
- constructor(props: ZeroExInstantProps) {
- super(props);
+ private static _createPartialStoreStateFromProps(props: ZeroExInstantProps): Partial<State> {
// TODO: Provider needs to not be hard-coded to injected web3.
const assetBuyer = AssetBuyer.getAssetBuyerForStandardRelayerAPIUrl(getProvider(), props.sraApiUrl);
const completeAssetMetaDataMap = {
@@ -42,7 +41,11 @@ export class ZeroExInstant extends React.Component<ZeroExInstantProps> {
selectedAsset: assetUtils.createAssetFromAssetData(props.assetData, completeAssetMetaDataMap),
assetMetaDataMap: completeAssetMetaDataMap,
};
- this.store = store.create(storeStateFromProps);
+ return storeStateFromProps;
+ }
+ constructor(props: ZeroExInstantProps) {
+ super(props);
+ this.store = store.create(ZeroExInstant._createPartialStoreStateFromProps(this.props));
// tslint:disable-next-line:no-floating-promises
asyncData.fetchAndDispatchToStore(this.store);
}