小编vgs*_*ngh的帖子

React-Redux中的路由问题

我是React-Redux生态系统的新手,通过尝试简单的应用程序来学习.在这种情况下,我正在尝试如何在react-redux应用程序中工作.基本上,这个想法是:

  1. 单击链接(反应路由器组件)导航到新页面
  2. 成功完成分派的异步操作后,导航到新页面.

这是我的代码

import React from 'react'
import {Link} from 'react-router'
import {routerActions} from 'react-router-redux'
import {connect} from 'react-redux'

class App extends React.Component {
  render() {
    // And you have access to the selected fields of the State too!
    return (
        <div>
            <header>
                Links:
                {' '}
                <Link to="/">Home</Link>
                {' '}
                <Link to="/foo">Foo</Link>
                {' '}
                <Link to="/bar">Bar</Link>
            </header>
            <div>
                <button onClick={() => routerActions.push('/foo')}>Go to /foo</button>
            </div>
        </div>
    )
  }
}
export default connect(null, null)(App);
===================================================================
import React from 'react'
import …
Run Code Online (Sandbox Code Playgroud)

react-redux

9
推荐指数
1
解决办法
481
查看次数

标签 统计

react-redux ×1