我正在用react和redux工具包编写一个普通的web应用程序,我想最终把它变成一个带有electronic的桌面应用程序。我已经解决了react部分,但redux似乎不起作用。我已经像往常一样在react应用程序的index.js上设置了商店提供商,但我猜这可能是electronic使用的另一种方式?
import React from 'react';
import ReactDOM from 'react-dom/client';
import store from './store';
import { Provider } from 'react-redux';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<Provider store={store}>
.....
.....
.....
</Provider>
);
您已经解决了吗?我在你的代码中没有发现任何特别奇怪的地方
请检查redux存储的路径
我以前使用过react+电子+打字
共享react文件夹内src文件夹中的index.tsx文件。
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import { store } from './store';
import { Provider } from 'react-redux';
// ↓ You can ignore the code below.
declare global {
interface Window {
Kakao: any;
Naver: any;
}
}
// ↑ You can ignore the code below.
const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);
root.render(
<React.StrictMode>
<Provider store={store}>
<App />
</Provider>
</React.StrictMode>
);
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://create-react-app.dev/docs/measuring-performance/
reportWebVitals();
希望这对你有帮助!