Skip to content

Commit

Permalink
admin: Fix store subscription ordering in compose page.
Browse files Browse the repository at this point in the history
Fixes #13.
  • Loading branch information
octavore committed Jun 3, 2018
1 parent f1c19c1 commit 4b23095
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions admin/src/js/pages/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ export default class PagePage extends React.Component<
}

componentDidMount() {
// must subscribe to page store events before triggering events
this.pageStore.subscribe('page-index', (page) => {
this.setState({
pageTitle: page.title,
contents: page.contents,
});
});

// handle animations
this.pageRef.current.addEventListener('mousedown', (e: any) => {
this._clickStart = e.target.classList;
Expand Down Expand Up @@ -96,13 +104,6 @@ export default class PagePage extends React.Component<
current: [{}],
});
}

this.pageStore.subscribe('page-index', (page) => {
this.setState({
pageTitle: page.title,
contents: page.contents,
});
});
}

componentWillUnmount() {
Expand Down

0 comments on commit 4b23095

Please sign in to comment.