-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
[0.49.1] Statically defined variables in a component do not persist after mounting #16226
Comments
A more simple example to demonstrate this issue. Appears to be an issue when using class variables in jsx/tsx.
|
TestComponent.SIZE is null when given to the style? |
|
I'm using the following workaround until this issue is explained and/or fixed;
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions. |
Could we have this reopened, it is an actual problem with a simple repro? |
I suspect this is more of an issue in React. I'm reopening, though I think you might have better luck checking out https://reactjs.org/community/support.html for pointers. |
Also getting |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions. |
It looks like your issue may refer to an older version of React Native. Can you reproduce the issue on the latest release, v0.55? |
Still happens on v0.55.4. It only occurs when using static properties. For now just use static methods instead. |
still happens on v0.56. |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions. |
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information. |
Is this a bug report?
Yes
Have you read the Contributing Guidelines?
Yes
Environment
Environment:
OS: macOS Sierra 10.12.6
Node: 7.7.1
Yarn: Not Found
npm: 5.0.3
Watchman: 4.7.0
Xcode: Xcode 9.0 Build version 9A235
Android Studio: Not Found
Packages: (wanted => installed)
react: 16.0.0-beta.5 => 16.0.0-beta.5
react-native: 0.49.1 => 0.49.1
Steps to Reproduce
I create a component called StaticComponent that declares a static class variable called
instance
to be null. Once this component is mounted it will set the static class variableinstance
to be itself.Then any other component that renders this component should be able to get the exact instance that was created upon mounting. What is returned every time is null...
I can confirm that this worked in 0.48.2. After upgrading to 0.49.1 it fails. I can recreate the issue using a fresh project from of react-native init.
If you actually go to the snack below you'll see that the instance is defined as it should be. Snack is still on react-native 0.48.0 so that's why. This blog post talks about the versions they're on.
"I am happy to announce... Expo SDK 21.0.0! It is based on React Native 0.48 “August”.
https://blog.expo.io/expo-sdk-21-0-0-is-now-available-be33b79921b7
If I copy paste the code I put into the snack back into my editor then run it with 0.49.1, the StaticComponent is not defined when it should be.
Reproducible Demo
https://snack.expo.io/Sy6djeN3W
The text was updated successfully, but these errors were encountered: