Skip to content
This repository was archived by the owner on Mar 27, 2018. It is now read-only.

Commit 87da45a

Browse files
committed
fix(waitForHnData): use combination of uuid and mapper to save loaded entities
1 parent d7c98aa commit 87da45a

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/DrupalPage/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class DrupalPage extends Component {
2525
async asyncBootstrap() {
2626
this.context.hnContext.state = {
2727
drupalPage: await this.loadData(this.props),
28-
entities: {},
28+
entities: [],
2929
};
3030
return true;
3131
}

src/EntityMapper.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,23 @@ class EntityMapper extends Component {
7575
async asyncBootstrap() {
7676
const { mapper, asyncMapper } = this.props;
7777
const { uuid, entityProps } = this.state;
78-
this.context.hnContext.state.entities[uuid] = await this.loadComponent({ uuid, mapper, asyncMapper, entityProps });
78+
this.context.hnContext.state.entities.push({
79+
mapper,
80+
uuid,
81+
component: await this.loadComponent({ uuid, mapper, asyncMapper, entityProps })
82+
});
7983
return true;
8084
}
8185

8286
/**
8387
* The first time this element is rendered, we always make sure the component and the Drupal page is loaded.
8488
*/
8589
componentWillMount() {
86-
const { uuid } = this.props;
87-
const state = getNested(() => this.context.hnContext.state.entities[uuid]);
90+
const { uuid, mapper } = this.props;
91+
const state = getNested(() => this.context.hnContext.state.entities.find(e => e.mapper === mapper && e.uuid === uuid).component);
92+
8893
if (state) {
8994
this.setState(state);
90-
delete this.context.hnContext.state.entities[uuid];
9195
} else {
9296
this.loadComponent(this.props);
9397
}

0 commit comments

Comments
 (0)