Uncaught ReferenceError: global is not defined at Menu.isBrowser
Current behaviour
App crashes on the web(chrome), When using Menu from react-native-paper,
Expected behavior
react-native-paper Menu should work fine on the web.
Uncaught ReferenceError: global is not defined
at Menu.isBrowser (index.ts:1)
at Menu.removeListeners (index.ts:1)
at Menu.componentWillUnmount (index.ts:1)
at callComponentWillUnmountWithTimer (index.ts:1)
at HTMLUnknownElement.callCallback (index.ts:1)
at Object.invokeGuardedCallbackDev (index.ts:1)
at invokeGuardedCallback (index.ts:1)
at safelyCallComponentWillUnmount (index.ts:1)
at commitUnmount (index.ts:1)
at commitNestedUnmounts (index.ts:1)
Code sample
https://snack.expo.dev/@phemonick/react-native-menu
import { Button, Paragraph, Menu, Divider, Provider } from 'react-native-paper';
export default class MyComponent extends React.Component {
state = {
visible: false,
};
_openMenu = () => this.setState({ visible: true });
_closeMenu = () => this.setState({ visible: false });
render() {
return (
<Provider>
<View
style={{
paddingTop: 50,
flexDirection: 'row',
justifyContent: 'center'
}}>
<Menu
visible={this.state.visible}
onDismiss={this._closeMenu}
anchor={
<Button onPress={this._openMenu}>Show menu</Button>
}
>
<Menu.Item onPress={() => {}} title="Item 1" />
<Menu.Item onPress={() => {}} title="Item 2" />
<Divider />
<Menu.Item onPress={() => {}} title="Item 3" />
</Menu>
</View>
</Provider>
);
}
}
Screenshots (if applicable)

What have you tried
added 👇🏽 script to my index.html file
<script>
global = globalThis
</script>
This is my temporary fix
Your Environment
| software | version |
|---|---|
| react-native-web | 0.16.2 |
| react-native | 0.64.0 |
| react-native-paper | 4.8.1 |
| node | 14.16.0 |
| npm or yarn | 1.22.4 |
Couldn't find version numbers for the following packages in the issue:
react-nativereact-native-paperreact-native-vector-iconsnpmyarn
Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3.
Hey! Thanks for opening the issue. The issue doesn't seem to contain a link to a repro (a snack.expo.io link or link to a GitHub repo under your username).
Can you provide a minimal repro which demonstrates the issue? A repro will help us debug the issue faster. Please try to keep the repro as small as possible and make sure that we can run it without additional setup.
Couldn't find version numbers for the following packages in the issue:
react-native-vector-iconsnpm
Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3.
The versions mentioned in the issue for the following packages differ from the latest versions on npm:
react-native(found:0.64.0, latest:0.65.1)react-native-paper(found:4.8.1, latest:4.9.2)yarn(found:1.22.4, latest:1.22.11)
Can you verify that the issue still exists after upgrading to the latest versions of these packages?
Hello 👋, this issue has been open for more than a month without a repro or any activity. If the issue is still present in the latest version, please provide a repro or leave a comment within 7 days to keep it open, otherwise it will be closed automatically. If you found a solution or workaround for the issue, please comment here for others to find. If this issue is critical for you, please consider sending a pull request to fix it.