Giter Site home page Giter Site logo

Comments (8)

CJY0208 avatar CJY0208 commented on August 26, 2024

有一定难度,因为 cache-route 依附于 react-router 实现,但目前遇到的是 react-router 也没有做到的问题,如果需要支持的话,可能会是一些 hack 或者有味道的代码,很难适应所有的使用者,甚至会造成其他的问题,从收益上来说也许并不适宜支持这个问题,除非 react-router 本身对此情况有通用解决方案

也有方法:将 when 设置为 always ,业务代码中记录跳转前后的路由路径,提供方法判断两者的前后关系,再借助 dropCache 方法手动取消缓存,理论上可以实现此功能

from react-router-cache-route.

qiuziz avatar qiuziz commented on August 26, 2024

确实, 我在路由配置中添加路由顺序处理吧

另外,behavior这个能暴露多点参数吗 比如是cache还是recover,

在写入场动画和出场动画,发现加了入场动画(translateX(100%) => translateX(0))后,back也是会触发这个,每个页面在didRecover移除这个太麻烦了

或者你有什么其他处理方式吗

from react-router-cache-route.

CJY0208 avatar CJY0208 commented on August 26, 2024

这个期望的目的是更好地控制转场动画吗?我在想如何让 cache-route 直接支持转场动画的设计,如果暴露 isCached 或者 isRevover 似乎还不够灵活

from react-router-cache-route.

qiuziz avatar qiuziz commented on August 26, 2024

是的,但目前看来,cache-route 入场动画无法完美实现,我无法获知当前页面是否后退而取消入场动画。

如果按照ReactCSSTransitionGroup 来进行className的动态变换就完美了

是否考虑下先暴露出isCached/isRevover 来过渡下呢

from react-router-cache-route.

CJY0208 avatar CJY0208 commented on August 26, 2024

我期望能直接走到支持 TransitionGroup 这一步上,但目前没时间做...需要到 6 月份了

from react-router-cache-route.

qiuziz avatar qiuziz commented on August 26, 2024

那先hack下吧 项目现在中需要用到

感谢

from react-router-cache-route.

ellisonLou avatar ellisonLou commented on August 26, 2024

那先hack下吧 项目现在中需要用到

感谢
请问你是怎么hack的呢?我们项目里面用到了多个tab缓存页面,在用reduxRouter.push 或者 浏览器的前进后退都会丢失缓存。感谢!

from react-router-cache-route.

qiuziz avatar qiuziz commented on August 26, 2024

@ellisonLou 不是太明白你说的 如果 是点击浏览器前进后退无法缓存的话,上面@CJY0208 有提供方案

也有方法:将 when 设置为 always ,业务代码中记录跳转前后的路由路径,提供方法判断两者的前后关系,再借助 dropCache 方法手动取消缓存,理论上可以实现此功能

如果是做路由控制的话,需要自己hack behavior 提供的参数 来回切换显示和隐藏 通过变量累加来判断是前进还是后退 但这种方案不太理想 还是有少数情况下出现错误动画

from react-router-cache-route.

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.