首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Uncaught:"[object Object]“在JSON.parse (<anonymous>)是无效的JSON

Uncaught:"[object Object]“在JSON.parse (<anonymous>)是无效的JSON
EN

Stack Overflow用户
提问于 2022-11-16 09:32:34
回答 2查看 308关注 0票数 0
代码语言:javascript
运行
复制
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);

代码语言:javascript
运行
复制
     client.fetch(query).then((data) => {
       setUser(data[0]);
   })
   }, []);


   useEffect(()=>{
       scrollRef.current.scrollTo(0, 0);
    
     },[])
EN

Stack Overflow用户

发布于 2022-11-16 09:38:41

当您将数据存储在本地存储时,请使用JSON.stringify(data)而不是直接存储数据。

票数 1
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74458109

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档