Skip to content

Instantly share code, notes, and snippets.

@jehartzog
Last active March 5, 2021 17:49
Show Gist options
  • Save jehartzog/1565654ec70bc469a0327ef95d990f17 to your computer and use it in GitHub Desktop.
Save jehartzog/1565654ec70bc469a0327ef95d990f17 to your computer and use it in GitHub Desktop.
react-navigation-drawer 2.5.0 prevent initial render flash
diff --git a/node_modules/react-navigation-drawer/lib/module/views/Drawer.js b/node_modules/react-navigation-drawer/lib/module/views/Drawer.js
index 352ca07..0f5dad4 100644
--- a/node_modules/react-navigation-drawer/lib/module/views/Drawer.js
+++ b/node_modules/react-navigation-drawer/lib/module/views/Drawer.js
@@ -60,6 +60,10 @@ export default class Drawer extends React.PureComponent {
constructor(...args) {
super(...args);
+ _defineProperty(this, "state", {
+ isReady: false,
+ })
+
_defineProperty(this, "clock", new Clock());
_defineProperty(this, "isDrawerTypeFront", new Value(this.props.drawerType === 'front' ? TRUE : FALSE));
@@ -211,7 +215,10 @@ export default class Drawer extends React.PureComponent {
// Show it in the next frame when layout is available
// If we don't delay it until the next frame, there's a visible flicker
- requestAnimationFrame(() => requestAnimationFrame(() => this.drawerOpacity.setValue(1)));
+ setTimeout(() => {
+ this.drawerOpacity.setValue(1);
+ this.setState({ isReady: true }); // Without this, the invisible content can grab touches
+ }, 500);
});
_defineProperty(this, "toggleDrawer", open => {
@@ -361,7 +368,7 @@ export default class Drawer extends React.PureComponent {
opacity: this.drawerOpacity,
zIndex: drawerType === 'back' ? -1 : 0
}, drawerStyle]
- }, renderDrawerContent({
+ }, this.state.isReady && renderDrawerContent({
progress: this.progress
})))));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment