Skip to content
This repository has been archived by the owner on Apr 29, 2023. It is now read-only.

Issue 54, basic SSR without treeshaking location.state and location.actions #67

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@ function wrapHistory(keys) {

export var location = {
state: {
pathname: window.location.pathname,
previous: window.location.pathname
pathname: typeof window === 'undefined' ? '' : window.location.pathname,
previous: typeof window === 'undefined' ? '' : window.location.pathname
},
actions: {
go: function(pathname) {
history.pushState(null, "", pathname)
return function(state, actions) {
typeof history === 'undefined'
? actions.set({ pathname: pathname, previous: state.pathname })
: history.pushState(null, "", pathname)
}
},
set: function(data) {
return data
Expand Down