-
Notifications
You must be signed in to change notification settings - Fork 23
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
Can't find variable SafeArea periodically #14
Comments
I believe I had this incorrectly defined in a screen that was being called periodically. |
It's happening again with the above code. Additional notes, I'm running RN 0.57 and Mobx 5.9.0. |
Any help would be much appreciated. It appears as if some sort of race condition is impacting whether we can get a defined value. This is also impacting dynamic layouts such as when using libraries such as recyclerlistview that needs to know heights when rendering or re-rendering. In some of those instances we're getting varied values of undefined values consistently sometimes and others periodically. |
@pribeh I'm not sure about Mobx because I don't use it. export class YourView extends React.Component<Props, State> {
onSafeAreaInsetsDidChange = this.onSafeAreaInsetsDidChange.bind(this)
componentWillMount(): void {
SafeArea.getSafeAreaInsetsForRootView()
.then(result => this.onSafeAreaInsetsDidChange(result))
}
componentDidMount(): void {
SafeArea.addEventListener('safeAreaInsetsForRootViewDidChange', this.onSafeAreaInsetsDidChange)
}
componentWillUnmount(): void {
SafeArea.removeEventListener('safeAreaInsetsForRootViewDidChange', this.onSafeAreaInsetsDidChange)
}
onSafeAreaInsetsDidChange(result: { safeAreaInsets: SafeAreaInsets }): void {
// Update state here
}
} |
Thanks for this superb lib. I think I might have something setup wrong or perhaps there's a bug but I'm receiving a "can't find ... variable" error periodically when loading the app in development mode.
Below is how I'm integrating safearea in my components/screens. Let me know if there's something wrong with it.
The text was updated successfully, but these errors were encountered: