#javascript #reactjs #react-native #redux #electron
Вопрос:
Поэтому я пытаюсь загрузить собственное веб-приложение React для загрузки внутри electron. Это отлично работает через RNW.
Однако в тот момент, когда я пытаюсь запустить его внутри Electron, я получаю это:
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
Я создал игрушечный рендеринг для своего 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>
);
}
Это не работает и выдает ошибку
Однако это:
render() {
return (
<View style={{ backgroundColor: "red" }}>
<Text>Test!</Text>
</View>
);
}
Отлично работает в электроне.
Оба они отлично работают в обычной родной сети React.
Что здесь может происходить, что вызывает эту ошибку? Похоже, это не имеет ничего общего с крючками, и странно, что это прекрасно работает в Интернете, но не в электроне.