流星认证和反应路由器

时间:2016-07-19 14:45:57

标签: authentication meteor reactjs react-router

当我使用accounts-password包登录时,如何让meteor重新渲染我的组件?

我的react-router路由是:

import React, { Component } from 'react'
import ReactDOM from 'react-dom'
import { Router, Route, IndexRoute, browserHistory } from 'react-router'

import App from './containers/App'
import Recordings from './containers/Recordings'
import LandingPage from './containers/LandingPage'

import { BloodPressure } from '../collections/BloodPressure'

const routes = (
    <Router history={browserHistory}>
        <Route path="/" component={App}>
            <IndexRoute component={LandingPage} />
            <Route path="dashboard" component={Recordings} />
        </Route>
    </Router>
)

Meteor.startup( ()=> {
    ReactDOM.render(routes, document.querySelector('.render-target'))
})

我的应用程序组件是:

import React, { Component } from 'react'
import { createContainer } from 'meteor/react-meteor-data'
import { browserHistory } from 'react-router'

import Header from './Header'

class App extends Component {
    constructor(props) {
        super(props)
    }

    render() {
        return(
            <div>
                <div className="ui four container">
                    <Header />
                    {this.props.children}
                </div>

                <div className="footer">
                    <p>Designed and Developed by <a href="http://thomashoadley.co.uk" target="_blank">Thomas Hoadley</a></p>
                </div>
            </div>              
        )       
    }
}

export default createContainer(() => {
    return {
        signedIn: Meteor.userId()
    }
}, App)

当我登录时,我希望页面能够使用正确的路由自动重新加载,但是我不得不手动重新加载页面以重定向它。

非常感谢有关此问题的任何帮助!

0 个答案:

没有答案