visionmedia / page.js

Micro client-side router inspired by the Express router

Home Page:http://visionmedia.github.com/page.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

window is undefined

JosephScript opened this issue · comments

I have the following code:

  console.log(window)
  page(encodeURI(path), state, dispatch, push)

As you can see, the console log shows window is an object, yet the page transition fails.

image

It happens in this line of code: this.title = (hasDocument && window.document.title);

Any idea why the window might be undefined? (This is in the browser, not SSR.)

Thanks!

Reading through the source code, I found that the window property can be set using the configure method. Try this:

page.configure({window:window})

(not sure why this would be required to set manually)

I ran into this as well...why in the world do we have to set page.configure({window:window}) to make this library work?

had the same problem, got the error
Cannot read property 'document' of undefined
thanks, @kjantzer