Uncaught SyntaxError: "[object Object]" is not valid JSON
at JSON.parse (<anonymous>)
vendors~main.chunk.js:32926 The above error occurred in the <Home> component:
at Home (http://localhost:3000/static/js/main.chunk.js:1640:99)
at RenderedRoute (http://localhost:3000/static/js/vendors~main.chunk.js:131876:5)
at Routes (http://localhost:3000/static/js/vendors~main.chunk.js:132298:5)
at App
at Router (http://localhost:3000/static/js/vendors~main.chunk.js:132236:15)
at BrowserRouter (http://localhost:3000/static/js/vendors~main.chunk.js:130557:5)
Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries.
console.<computed> @ vendors~main.chunk.js:32926
localhost/:1 Uncaught (in promise) SyntaxError: "[object Object]" is not valid JSON
at JSON.parse (<anonymous>)
at Home (main.chunk.js:1643:72)
VM23:2 Uncaught ReferenceError: process is not defined
**CODE**
const = () => { const scrollRef = useRef(null);const userInfo = localStorage.getItem('user') !==‘未定义’?JSON.parse(localStorage.getItem('user')):localStorage.clear();useEffect(() => { const = userQuery(userInfo?.sub);
client.fetch(query).then((data) => {
setUser(data[0]);
})
}, []);
useEffect(()=>{
scrollRef.current.scrollTo(0, 0);
},[])
发布于 2022-11-16 09:38:41
当您将数据存储在本地存储时,请使用JSON.stringify(data)
而不是直接存储数据。
https://stackoverflow.com/questions/74458109
复制相似问题