mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
fix client/router
This commit is contained in:
parent
cb11c7cbc6
commit
e51c7eabf1
|
@ -26,7 +26,7 @@ export default class Router {
|
||||||
|
|
||||||
onPopState (e) {
|
onPopState (e) {
|
||||||
this.abortComponentLoad()
|
this.abortComponentLoad()
|
||||||
const cur = this.currentComponent
|
const cur = this.currentComponentData.id
|
||||||
const url = getURL()
|
const url = getURL()
|
||||||
const { fromComponent, route } = e.state || {}
|
const { fromComponent, route } = e.state || {}
|
||||||
if (fromComponent && cur && fromComponent === cur) {
|
if (fromComponent && cur && fromComponent === cur) {
|
||||||
|
@ -44,7 +44,6 @@ export default class Router {
|
||||||
location.reload()
|
location.reload()
|
||||||
} else {
|
} else {
|
||||||
this.currentRoute = route || toRoute(location.pathname)
|
this.currentRoute = route || toRoute(location.pathname)
|
||||||
this.currentComponent = data.Component.displayName
|
|
||||||
this.currentComponentData = data
|
this.currentComponentData = data
|
||||||
this.set(url)
|
this.set(url)
|
||||||
}
|
}
|
||||||
|
@ -161,7 +160,7 @@ export default class Router {
|
||||||
if (err) {
|
if (err) {
|
||||||
if (!cancelled) fn(err)
|
if (!cancelled) fn(err)
|
||||||
} else {
|
} else {
|
||||||
const d = { data, id: createUid() }
|
const d = { ...data, id: createUid() }
|
||||||
// we update the cache even if cancelled
|
// we update the cache even if cancelled
|
||||||
if (!this.components[route]) {
|
if (!this.components[route]) {
|
||||||
this.components[route] = d
|
this.components[route] = d
|
||||||
|
|
|
@ -26,8 +26,8 @@ export default class App extends Component {
|
||||||
|
|
||||||
this.close = router.subscribe(() => {
|
this.close = router.subscribe(() => {
|
||||||
const state = propsToState({
|
const state = propsToState({
|
||||||
router,
|
...router.currentComponentData,
|
||||||
data: router.currentComponentData
|
router
|
||||||
})
|
})
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue