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

displayName? not available in instance... #2285

Closed
cigzigwon opened this issue Oct 2, 2014 · 4 comments
Closed

displayName? not available in instance... #2285

cigzigwon opened this issue Oct 2, 2014 · 4 comments

Comments

@cigzigwon
Copy link

JSX will infer the component's name from the variable assignment and specify the class's displayName accordingly.

Really?

This is not available in a class instance of React. Not even if it is set explicitly. Also, componentDidUpdate prevState seems to be the current state... I'm not sure if this is because of how browserify is bundling the JS or what. for v0.11.2. I've tried everything and prevState always logs the current state post update.
selection_001

@syranide
Copy link
Contributor

syranide commented Oct 2, 2014

React does not deep clone props/state, if you want the benefits of using prevProps and prevState then you need to ensure the objects are immutable/not mutated yourself.

@waldreiter
Copy link
Contributor

@cigzigwon You can get the displayName with this.constructor.displayName. It is a bit ugly, but it's only useful for debugging anyway.

@cigzigwon
Copy link
Author

Ok, I didn't realize that since I'm new to React. Thx guys!

@syranide
Copy link
Contributor

syranide commented Oct 2, 2014

@cigzigwon There is almost always someone knowledgeable online in our IRC channel, for all your getting-started related questions, if you feel inclined.

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

No branches or pull requests

3 participants