Skip to content

Commit

Permalink
React on popstate event
Browse files Browse the repository at this point in the history
  • Loading branch information
yishn committed Jan 21, 2020
1 parent c92819a commit 7caa25d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ export default class App extends Component {
}
})

window.addEventListener('popstate', evt => {
this.handleDataChange({data: this.parseDiagramFromUrl()})
})

window.addEventListener('beforeunload', evt => {
if (
this.state.diagram.nodes.length > 0 ||
Expand Down Expand Up @@ -100,7 +104,7 @@ export default class App extends Component {
let base = window.location.href.split('#')[0]

let url = base + '#' + encoded
window.history.replaceState(null, null, '#' + encoded)
window.history.pushState(null, null, '#' + encoded)

let success = copyText(url)

Expand Down

0 comments on commit 7caa25d

Please sign in to comment.