Skip to content

Non-state variables in Components #3735

Discussion options

You must be logged in to vote

The other day I stumbled across a comment in Preact internals discussion suggesting you can only store values in a component's state, and the reason was something to do with the component forgetting it.

Huh, that would be new to me. I'm curious where you read that. It's perfectly fine to store things on the class instance itself and we even do that ourselves in all of our addons like hooks/signals/etc. Storing things on the class instance is a fundamental aspect of having class components in the first place.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mikekasprzak
Comment options

Answer selected by mikekasprzak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants