Skip to content
This repository has been archived by the owner on Aug 19, 2022. It is now read-only.

Indirectly calling setState from constructor doesn't trigger render #984

Closed
johnfn opened this issue Apr 5, 2018 · 4 comments
Closed

Indirectly calling setState from constructor doesn't trigger render #984

johnfn opened this issue Apr 5, 2018 · 4 comments

Comments

@johnfn
Copy link

johnfn commented Apr 5, 2018

Here's some example code (in TypeScript)

class TestComponent extends React.Component<{}, {foo: number}> {
  constructor(props: {}) {
    super(props);

    this.state = { foo: 1 };

    setTimeout(() => this.setState({ foo: 5 }), 1000);
  }

  render(): JSX.Element {
    return <div>{ this.state.foo }</div>;
  }
}

const TestComponentWrapped = Radium(TestComponent);

Without wrapping the component in Radium, foo gets set to 5 after a second.

Once I wrap with Radium, foo stays 1.

@ryan-roemer
Copy link
Member

Hmmm.... that should work. Can you open up a minimal repository with install + error reproduction steps for us to clone and verify? Thanks!

@stevenmusumeche
Copy link
Contributor

ping @johnfn

@kylecesmat
Copy link
Contributor

Closing for inactivity. @johnfn if this is still an issue let us know and we can reopen!

@johnfn
Copy link
Author

johnfn commented Dec 17, 2018

I'm certain this is still an issue and shouldn't be closed, however I do not have time to create a repo.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants