page.js icon indicating copy to clipboard operation
page.js copied to clipboard

window is undefined

Open JosephScript opened this issue 5 years ago • 4 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!

JosephScript avatar May 06 '19 21:05 JosephScript

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)

kjantzer avatar May 15 '19 17:05 kjantzer

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

btknorr avatar Nov 22 '19 20:11 btknorr

@btknorr PRs welcome

matthewp avatar Nov 24 '19 17:11 matthewp

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

blubbll avatar May 23 '20 09:05 blubbll