<commit_before>import {Meteor} from 'meteor/meteor';
import React from 'react';
import ReactDOM from 'react-dom';
import createBrowserHistory from 'history/createBrowserHistory'
import {BrowserRouter as Router, Switch, Route, Redirect} from 'react-router-dom';
import {Tracker} from 'meteor/tracker';

import Signup from './../imports/ui/Signup';
import Link from './../imports/ui/Link';
import NotFound from './../imports/ui/NotFound'
import Login from './../imports/ui/Login';

//Client-side routing using React-Router (react-router-dom v4)
const browserHistory = createBrowserHistory();
const unauthenticatedPages = ['/', '/signup'];
const authenticatedPage = ['/links'];

const routes = (
    <Router history={browserHistory}>
        <Switch>
            <Route exact path="/" render={() => {
                return Meteor.userId() ? <Redirect to="/links" /> : <Login />
            }} />
            <Route path="/signup" render={() => {
                return Meteor.userId() ? <Redirect to="/links" /> : <Signup />
            }} />
            <Route path="/links" render={() => {
                return Meteor.userId() ? <Link /> : <Redirect to="/"/>
            }} />
            <Route path="*" component={NotFound} />
        </Switch>
    </Router>
);

Tracker.autorun(() => {
    //Keep track of authentication status
    const isAuthenticated = !!Meteor.userId();
    const pathname = browserHistory.location.pathname;
    const isUnauthenticatedPage = unauthenticatedPages.includes(pathname);
    const isAuthenticatedPage = authenticatedPage.includes(pathname);

    if(isAuthenticated && isUnauthenticatedPage) {
        browserHistory.push('/links');
    } else if(!isAuthenticated && isAuthenticatedPage){
        browserHistory.push('/');
    }
});

Meteor.startup(() => {
        ReactDOM.render(routes, document.getElementById('app'));
    }
);<commit_msg>Bug fixed with client router<commit_after>import {Meteor} from 'meteor/meteor';
import React from 'react';
import ReactDOM from 'react-dom';
import createBrowserHistory from 'history/createBrowserHistory'
import {Router, Switch, Route, Redirect} from 'react-router-dom';
import {Tracker} from 'meteor/tracker';

import Signup from './../imports/ui/Signup';
import Link from './../imports/ui/Link';
import NotFound from './../imports/ui/NotFound'
import Login from './../imports/ui/Login';

//Client-side routing using React-Router (react-router-dom v4)
const browserHistory = createBrowserHistory();
const unauthenticatedPages = ['/', '/signup'];
const authenticatedPage = ['/links'];

const routes = (
    <Router history={browserHistory}>
        <Switch>
            <Route exact path="/" render={() => {
                return Meteor.userId() ? <Redirect to="/links" /> : <Login />
            }} />
            <Route path="/signup" render={() => {
                return Meteor.userId() ? <Redirect to="/links" /> : <Signup />
            }} />
            <Route path="/links" render={() => {
                return Meteor.userId() ? <Link to="/links" /> : <Redirect to="/"/>
            }} />
            <Route path="*" component={NotFound} />
        </Switch>
    </Router>
);

Tracker.autorun(() => {
    //Keep track of authentication status
    const isAuthenticated = !!Meteor.userId();
    const pathname = browserHistory.location.pathname;
    const isUnauthenticatedPage = unauthenticatedPages.includes(pathname);
    const isAuthenticatedPage = authenticatedPage.includes(pathname);

    if(isAuthenticated && isUnauthenticatedPage) {
        browserHistory.push('/links');
    } else if(!isAuthenticated && isAuthenticatedPage){
        browserHistory.push('/');
    }
});

Meteor.startup(() => {
        ReactDOM.render(routes, document.getElementById('app'));
    }
);
{'fraction_non_alphanumeric': 0.1623342175066313, 'fraction_numerical': 0.0005305039787798408, 'mean_word_length': 2.9904761904761905, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6459889', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1056, 'n_words': 249}