Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

componentDidMount is not triggered on inner components #2453

Closed
shelldandy opened this issue Jul 3, 2017 · 3 comments
Closed

componentDidMount is not triggered on inner components #2453

shelldandy opened this issue Jul 3, 2017 · 3 comments

Comments

@shelldandy
Copy link

shelldandy commented Jul 3, 2017

export default class Example extends Component {
  constructor (props) {
    super(props)
    this.state = {
      loaded: false
    }
  }

  componentDidMount () {
    this.setState({
      loaded: true
    })
  }

  render () {
    let { loaded } = this.state
    return loaded
      ? <p>💕</p>
      : <p>Loading...</p>
  }
}

Everything stays in loaded false state probably because componentDidMount never gets triggered, my folder structure is

  • pages -> index.js
  • components -> example.js

Running on latest version of next.js

Is this behavior intended?

@sergiodxa
Copy link
Contributor

It's not intended, and in fact Next.js should not be affecting that, can you provide a repo to reproduce it? I think something else it's wrong 🤔

@timneutkens
Copy link
Member

I'll re-open when there's an example to reproduce.

@shelldandy
Copy link
Author

Thanks, I'm trying to make the example as minimal code as possible 😢

But basically im using dotenv and also next-routes with some getInitialProps maybe its too much stuff in the mix??

@lock lock bot locked as resolved and limited conversation to collaborators May 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants