#reactjs
Вопрос:
Я уже добавил recoil ,RecoilPresist,и оба они импортированы в мой индекс, файл js, но я получаю исключение во время выполнения во время запуска приложения . Мое приложение ,основанное на reactjs, добавило все зависимости, требуемые для приложения, но я не знаю, почему у меня возникают проблемы такого типа
Вот полный перечень вопросов
TypeError: recoil_persist__WEBPACK_IMPORTED_MODULE_3___default(...) is not a function
Module.<anonymous>
D:/spring-chat/src/index.js:9
6 | import App from "./App";
7 | import * as serviceWorker from "./serviceWorker";
8 |
> 9 | const { RecoilPersist, updateState } = recoilPersist([], {
10 | key: "recoil-persist",
11 | storage: sessionStorage,
12 | });
View compiled
Module../src/index.js
http://localhost:3000/static/js/main.chunk.js:1431:30
__webpack_require__
D:/spring-chat/webpack/bootstrap:851
848 |
849 | __webpack_require__.$Refresh$.init();
850 | try {
> 851 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId));
| ^ 852 | } finally {
853 | __webpack_require__.$Refresh$.cleanup(moduleId);
854 | }
View compiled
fn
D:/spring-chat/webpack/bootstrap:150
147 | );
148 | hotCurrentParents = [];
149 | }
> 150 | return __webpack_require__(request);
| ^ 151 | };
152 | var ObjectFactory = function ObjectFactory(name) {
153 | return {
View compiled
1
http://localhost:3000/static/js/main.chunk.js:2922:18
__webpack_require__
D:/spring-chat/webpack/bootstrap:851
848 |
849 | __webpack_require__.$Refresh$.init();
850 | try {
> 851 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId));
| ^ 852 | } finally {
853 | __webpack_require__.$Refresh$.cleanup(moduleId);
854 | }
View compiled
checkDeferredModules
D:/spring-chat/webpack/bootstrap:45
42 | }
43 | if(fulfilled) {
44 | deferredModules.splice(i--, 1);
> 45 | result = __webpack_require__(__webpack_require__.s = deferredModule[0]);
| ^ 46 | }
47 | }
48 |
View compiled
Array.webpackJsonpCallback [as push]
D:/spring-chat/webpack/bootstrap:32
29 | deferredModules.push.apply(deferredModules, executeModules || []);
30 |
31 | // run deferred modules when all chunks ready
> 32 | return checkDeferredModules();
| ^ 33 | };
34 | function checkDeferredModules() {
35 | var resu<
View compiled
(anonymous function)
http://localhost:3000/static/js/main.chunk.js:1:75
index.js
import React from "react";
import ReactDOM from "react-dom";
import { RecoilRoot } from "recoil";
import recoilPersist from "recoil-persist";
import "./index.css";
import App from "./App";
import * as serviceWorker from "./serviceWorker";
const { RecoilPersist, updateState } = recoilPersist([], {
key: "recoil-persist",
storage: sessionStorage,
});
ReactDOM.render(
<RecoilRoot initializeState={updateState}>
<RecoilPersist />
<App />
</RecoilRoot>,
document.getElementById("root")
);
serviceWorker.unregister();
пакет.json
{
"name": "spring-chat",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"antd": "^4.16.13",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-icons": "^4.3.1",
"react-router-dom": "^5.3.0",
"react-scripts": "4.0.3",
"react-scroll-to-bottom": "^4.1.2",
"react-stomp": "^5.1.0",
"recoil": "^0.4.1",
"recoil-persist": "^3.0.0",
"web-vitals": "^1.1.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
What is the reason for recoil persist not working in index file .how
to use recoil Persist in indexJs file