采用 reactjs 开发时, redux 和 react-route 是怎么配合使用的? - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
sjrong
V2EX    React

采用 reactjs 开发时, redux 和 react-route 是怎么配合使用的?

  •  
  •   sjrong 2016-01-09 17:34:54 +08:00
    这是一个创建于 3565 天前的主题,其中的信息可能已经有所发展或是发生改变。

    万能的 V 友中用 reactjs 开发项目的多不?

    本人常年从事服务器端开发,是个前端小白;
    最近 reactjs 的 component 概念挺吸引我的,准备借着 reactjs 利用业余项目一举攻下前端,正式跨入全栈的行列~

    理想丰满,现实骨感;

    reactjs 的概念还真是挺多的,经过几周的学习算是入门啦,配合 redux 使用可以写些简单的页面啦。
    随着能力的提升,思绪的发散,想实现的功能也越来越多~

    可是当我想实现一个稍微整个复杂些的项目,尤其是页面比较多的时候,就遇到问题啦,几个页面之间来回跳转的逻辑写着特别 ugly 。

    后来查资料发现原来前端的单页应用,是离不开一个叫“路由”的东西的;
    react-route 是其中比较成熟的解决方案,但是 react-route 和 redux 在集成的时候总感觉有些别扭,想问问大伙这块是怎么处理的?

    另:我的大部分技术选型都是参考百度的一个项目 https://github.com/my-fe/wiki/issues/1

    4 条回复    2016-01-11 15:07:37 +08:00
    zsx
        1
    zsx  
       2016-01-09 19:08:43 +08:00
    Redux 作者有 redux-simple-router ( https://github.com/rackt/redux-simple-router ),
    在这之前,通常用 redux-router ( https://github.com/acdlite/redux-router )来互调。
    zsx
        2
    zsx  
       2016-01-09 19:10:57 +08:00
    Redux 的 real-world 的 example 就是用 redux-router 实现的,当然也有 PR 把它改写成 redux-simple-router (可惜我来迟了不然就能刷 Contributor 了(逃)),你可以对比着看。

    这里还有一些 Redux 的 examples: https://github.com/xgrommx/awesome-redux
    plqws
        3
    plqws  
       2016-01-09 19:18:35 +08:00
    推荐用 redux-simple-router ,坑少一点
    sjrong
        4
    sjrong  
    OP
       2016-01-11 15:07:37 +08:00
    @plqws @zsx 感谢感谢,我这就去研究研究~
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2980 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 26ms UTC 13:45 PVG 21:45 LAX 06:45 JFK 09:45
    Do have faith in what you're doing.
    ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86