Coder Social home page Coder Social logo

Comments (6)

zhangyuang avatar zhangyuang commented on September 24, 2024

给最小复现

from egg-react-ssr.

yxbgithub1 avatar yxbgithub1 commented on September 24, 2024

首先我非常喜欢你们的脚手架,项目结构简洁干净,同时支持ts,我想要的实现是部分路由是ssr,其他部分是csr-spa

  1. 运行npm run csr会失败,报错Invariant failed: You should not use outside a (抱歉,昨天复制错误),我所知道的是因为路由嵌套问题
  2. 文档中提到__isBrowser__ 切换ssr和csr,但是因为第一步失败,导致无法研究剩下的实现

from egg-react-ssr.

i5ting avatar i5ting commented on September 24, 2024

@yxbgithub1 好的,我们查一下

from egg-react-ssr.

zhangyuang avatar zhangyuang commented on September 24, 2024

首先我非常喜欢你们的脚手架,项目结构简洁干净,同时支持ts,我想要的实现是部分路由是ssr,其他部分是csr-spa

  1. 运行npm run csr会失败,报错Invariant failed: You should not use outside a (抱歉,昨天复制错误),我所知道的是因为路由嵌套问题
  2. 文档中提到__isBrowser__ 切换ssr和csr,但是因为第一步失败,导致无法研究剩下的实现

给一个复现的仓库地址。你那个错我知道是什么原因是因为多个react-router实例冲突,这个错误我在很早的版本就修复了不知道你是不是改了什么代码导致出错
isBrowser 不是切换ssr/csr的只是一个标志环境变量而已
不支持路由级别的渲染模式模式定制,你通过config.type可以指定整个项目的渲染模式。有更多的疑问可以扫码进群交流

from egg-react-ssr.

Zero2key avatar Zero2key commented on September 24, 2024

我也遇到了这个问题,直接用 ykcli init 生成的 typescript 项目,没有改动任何代码,运行 npm run csr 报错 Error: Invariant failed: You should not use <Link> outside a <Router>

环境:
mac os 10.14.6
node 12.12.0
yk-cli 2.7.2

from egg-react-ssr.

zhangyuang avatar zhangyuang commented on September 24, 2024

@Zero2key @yxbgithub1 ts的example看了一下确实有问题,已修复,js的example没问题,可以看看commit具体改了哪个地方新的复制过去即可。或者重新init一遍项目

from egg-react-ssr.

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.