Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component - error only shows in Electron

Viewed 164

So I am trying to get a React Native Web app to load inside electron. It works great via RNW.

However the moment that I try to launch it inside Electron, I get this:

Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app  

I have creating a toy render for my App.js:

render() {
    return (
      <RootSiblingParent>
        <Provider store={store} context={ReactReduxContext}>
          <PersistGate persistor={persistor}>
            <ConnectedRouter history={history} context={ReactReduxContext}>
              <Layout>
                <View style={{ backgroundColor: "red" }}>
                  <Text>Test!</Text>
                </View>
              </Layout>
            </ConnectedRouter>
          </PersistGate>
        </Provider>
      </RootSiblingParent>
    );
}

This doesn't work and throws the error

However this:

render() {
    return (
                <View style={{ backgroundColor: "red" }}>
                  <Text>Test!</Text>
                </View>
    );
}

Works great in Electron.

Both of them work great in regular React Native Web.

What could be happening here that's causing this error? It doesn't seem to have anything to do with hooks, and it is odd that works fine on the web, but not in Electron.

0 Answers
Related