Skip to content

Commit

Permalink
fix: record history state before render (#140)
Browse files Browse the repository at this point in the history
* fix: record history state before render

* chore: typo
  • Loading branch information
ClarkXia authored Jul 7, 2020
1 parent f3819df commit 2acfa33
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ice/stark",
"version": "1.5.3",
"version": "1.5.4",
"description": "Icestark is a JavaScript library for multiple projects, Ice workbench solution.",
"scripts": {
"build": "rm -rf lib && tsc",
Expand Down
8 changes: 4 additions & 4 deletions src/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,11 @@ export default class AppRouter extends React.Component<AppRouterProps, AppRouter
// if AppRouter is unmounted, cancel all operations
if (this.unmounted) return;

this.setState({ url });

// setHistoryState after setState
// history in sub-application will not triggered callCapturedEventListeners for historyState is null
// setHistoryState before setState
// setState is only async batched when it is called inside a React event handler, otherwise it is sync
// make sure history state had beed recorded before render
setHistoryState(state);
this.setState({ url });

this.handleRouteChange(url, routeType);
};
Expand Down

0 comments on commit 2acfa33

Please sign in to comment.