question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Removal of Polyfill leads to window is not defined error in React web app with SSR

See original GitHub issue

After this update core@1.0.13-unstable.1

We are getting window is not defined error. Error points to …/…/src/RNComponents/index.ts

we are using custom aws config setup. we have set Amplify.configure(awsConfig) in redux provider wrapper file which executes amplify configure function outside of react component, I have also tried to call the Amplify.configure in componentDidMount function but still getting same error.

In older version of our project, we were using core@1.0.9, and it is working perfectly.

This is how our project setup is, This Provider.js component is imported inside all the pages to check user authentication.

provider.js

import React, { Component } from 'react'
import { Provider } from 'react-redux'
import store from '../store'
import { Auth } from 'aws-amplify'
import '../../awsConfig.js'

export default class ProviderWithAuth extends Component {
  ...
}

awsConfig.js

import Amplify from 'aws-amplify';
import { default as config } from '../../config'

Amplify.configure({ config })

If we are doing something wrong, please guide us to make correction in our project by providing best practice for the usage of Amplify.configure function.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dhanesh-kapadiyacommented, Oct 9, 2018

@haverchuck I have tested the unstable build in my project and it seems to be working. And I’ve checked latest stable build as well, that seems to be working too.

0reactions
github-actions[bot]commented, Jun 13, 2021

This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to solve "window is not defined" errors in React and Next.js
A different solution is to load your Scroll component using dynamic imports and the srr: false option.
Read more >
Window is not defined in Next.js React app - Stack Overflow
The error occurs because window is not yet available, while component is still mounting. You can access window object after component is mounted....
Read more >
How to solve Next.js window is not defined
Solve a the common ReferenceError: next.js window is not defined error that you may see when doing SSR & pre-rendering.
Read more >
Error Boundaries - React
A class component becomes an error boundary if it defines either (or both) of the lifecycle methods static getDerivedStateFromError() or componentDidCatch() .
Read more >
How to fix errors like ReferenceError Window is Not Defined in ...
innerWidth to set the initial value. Now, during SSR, the code executes on the server but the window object simply doesn't exist there....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found