-
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
我想给它支持ssr的组件,是否可行。 #50
Comments
我觉得还是最初switch组件的版本代码比较更好一点,之前并且应该是支持ssr吧 |
@LonelyFellas 刚为你测试了一下 |
@LonelyFellas 老的代码没有问题,但是有个问题 #45 ,里面使用了即将过时 API 所以使用 Context 来解决这个问题,同时解决了,可以跨组件使用 <Switch>
<div>
<Case as="span" condition={age < 6}>Preschool</Case>
</div>
</Switch> |
@LonelyFellas 所以有没有解决 ssr 的方法呢? createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. |
@jaywcjlove 你有觉得逻辑哪里不妥吗 |
@LonelyFellas 你这个差不多是我 v1 版本的逻辑循环子节点,去处理 v2 版本的逻辑是,加载 |
@LonelyFellas 代码逻辑更清晰简单,我发现我本地还有没有提交的代码 😄 |
主要是你的v2的版本用不单单是用了createContext,还用了useState,useEffect,这些钩子在有状态的变化,不支持ssr |
@LonelyFellas 移除冗余代码之后,简单多了。现在可能不支持ssr 需要在文件上添加 "use client" 没有用到 |
我看了有用到useReducer的, 差不多的意思跟useState。 |
@LonelyFellas 根据你给的示例,我看了 v1 的代码,进行了重构,升级 |
@jaywcjlove 可以。能够达到预期 |
@jaywcjlove 在Default这组件。我认为把prop属性的condition去除掉,不然我认为Default和Case没啥区别呀 |
@LonelyFellas Upgrade |
No description provided.
The text was updated successfully, but these errors were encountered: