Code Monkey home page Code Monkey logo

Comments (12)

geekact avatar geekact commented on June 8, 2024

你应该是开启了es module,import时后缀必须指定。切换到commonJS方案可解决问题,或者在执行node时加上--experimental-specifier-resolution=node也可解决问题。

我这边也看下如何解决在框架层面解决

from foca.

geekact avatar geekact commented on June 8, 2024

升级到 [email protected] 即可修复报错。之前都是在vite/webpack环境下使用,所以没有遇到node的问题

from foca.

linzeguang avatar linzeguang commented on June 8, 2024

升级到[email protected]就可以报修复错误。之前都是在vite/webpack环境下使用,所以没有遇到node的问题

升级到0.10.2解决了这个问题,但是新遇到了个问题就是next.js在node环境下运行没有localStorage和sessionStorage对象

from foca.

linzeguang avatar linzeguang commented on June 8, 2024

TypeError: Cannot destructure property 'store' of 'useReduxContext(...)' as it is null.
at useSelector (/Users/linzeguang/Desktop/yyz/my-app/node_modules/react-redux/lib/hooks/useSelector.js:50:7)
at useModel (file:///Users/linzeguang/Desktop/yyz/my-app/node_modules/foca/dist/index.mjs:756:10)
at Home (webpack-internal:///./src/pages/index.tsx:21:63)
at renderWithHooks (/Users/linzeguang/Desktop/yyz/my-app/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5448:16)
at renderIndeterminateComponent (/Users/linzeguang/Desktop/yyz/my-app/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5521:15)
at renderElement (/Users/linzeguang/Desktop/yyz/my-app/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5736:7)
at renderNodeDestructive (/Users/linzeguang/Desktop/yyz/my-app/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5875:11)
at renderNode (/Users/linzeguang/Desktop/yyz/my-app/node_modules/react-dom/cjs/react-dom-server.browser.development.js:6009:12)
at renderChildrenArray (/Users/linzeguang/Desktop/yyz/my-app/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5965:7)
at renderNodeDestructive (/Users/linzeguang/Desktop/yyz/my-app/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5897:7)
wait - compiling /_error (client and server)...
wait - compiling...
event - compiled client and server successfully in 97 ms (210 modules)
error - TypeError: Cannot destructure property 'store' of 'useReduxContext(...)' as it is null.

还有遇到这个报错,在使用useModel的时候

image

from foca.

geekact avatar geekact commented on June 8, 2024

你是要使用persist吗?这个应该是个无解的问题,redux-persist之前也讨论过这个,rt2zz/redux-persist#1008

目前只能判断是否ssr,然后换成 memoryStorage 。之前有想过使用cookie来实现,但是不确定是否为业界标准方案

from foca.

geekact avatar geekact commented on June 8, 2024

TypeError: Cannot destructure property 'store' of 'useReduxContext(...)' as it is null.

是否在入口加上了 FocaProvider标签?

from foca.

linzeguang avatar linzeguang commented on June 8, 2024

TypeError: Cannot destructure property 'store' of 'useReduxContext(...)' as it is null.

是否在入口加上了 FocaProvider标签?

忘记添加了不好意思,文档里没体现就疏忽了,您这边看文档要不要补充一下。

from foca.

geekact avatar geekact commented on June 8, 2024

https://foca.js.org/#/store?id=%e5%85%a5%e5%8f%a3
文档都有的

from foca.

geekact avatar geekact commented on June 8, 2024

SSR的持久化这块可以讲讲你的需求,我收集一下,这样做出来的功能也更符合用户习惯。

from foca.

linzeguang avatar linzeguang commented on June 8, 2024

https://foca.js.org/#/store?id=%e5%85%a5%e5%8f%a3 文档都有的

哦哦看到了,不好意思哈,感谢

from foca.

geekact avatar geekact commented on June 8, 2024

好的,希望这个库能让你准时下班,我这几天把nextjs的demo也放上去

from foca.

geekact avatar geekact commented on June 8, 2024

经过一段时间研究,发现foca暂时无法用在nextjs中。原因是store是单一的,而node进程是内存常驻的,这意味着store会被所有请求共享。我将在文档中体现这个问题。感谢体验以及非常抱歉

同时,通过查找资料,发现next.js不是唯一的seo解决方法,可以看看这篇文章:https://markdowner.net/article/73058307795021824

from foca.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.