ReactJS – Reactive router code in separate files

I am a newbie and am trying to learn redux with router. I want to make the route as a separate file. But it doesn’t work because I can’t pass dependencies. Below is the code in detail Information.

Work index.js also has routing:

import React from "react";
import ReactDOM from "react- dom";
import {Provider} from'react-redux';
import {ReduxRouter} from "redux-react-router";
import {Route} from "react-router"< br />
import createBrowserHistory from "history/lib/createBrowserHistory"
import configureStore from'./store';

import App from "./containers/App";< br />import Home from "./components/Home";
import Countries from "./components/Countries";
import {fetchData} from'./actions/actions';

const history = new createBrowserHistory();
const store = configureStore();

function loadData() {
store.dispatch(fetchData('https:/ /restcountries.eu/rest/v1/all'))
}

ReactDOM.render(

< br />






,
document.getElementById('root')
) ;

The following is the code I tried to split into separate routes.js

index.js

import'babel- core/polyfill';
import React from "react";
import ReactDOM from "react-dom";
import {Provider} from'react-redux';
import { ReduxRouter} from "redux-react-router";
import {Route} from "react-router"

import createBrowserHistory from "history/lib/createBrowserHistory"
import configureStore from './store';

import routes from "./routes";
import {fetchData} from'./actions/actions';

const history = new createBrowserHistory();
const store = configureStore();

ReactDOM.render(





,
document.getElementById('root')
);

routes.js

import React from "react";
import {Provider} from'react-redux ';
import {ReduxRouter} from "redux-react-router";
import {Route} from "react-router"


import App from ". /../containers/App";
import Home from "./../components/Home";
import Countries from "./../components/Countries";
< br />const router =





;

export default router ;

However, because the loadData function cannot be recognized, an error is thrown.

Please help.

< /div>

pass it as a child, please note that the parent is called a router:

< br /> { routes} 

There are no historical props for routing, routers.

Check the examples of Router.js and Route.js on my launcher: https ://github.com/DominicTobias/universal-react/tree/master/app

I am a novice and I am trying to learn redux with router. I want to route As a separate file. But it doesn’t work because I can’t pass dependencies. Below is the code details.

Working index.js also has routing:

import React from "react";
import ReactDOM from "react-dom";
import {Provider} from'react-redux';
import {ReduxRouter} from " redux-react-router";
import {Route} from "react-router"

import createBrowserHistory from "history/lib/createBrowserHistory"
import configureStore from'./store ';

import App from "./containers/App";
import Home from "./components/Home";
import Countries from "./components/Countries" ;
import {fetchData} from'./actions/actions';

const history = new createBrowserHistory();
const store = configureStore();
< br />function loadData() {
store.dispatch(fetchData('https://restcountries.eu/rest/v1/ all'))
}

ReactDOM.render(









,
document.getElementById('root' )
);

The following is the code I tried to split into separate routes.js

index.js

< pre>import’babel-core/polyfill’;
import React from “react”;
import ReactDOM from “react-dom”;
import {Provider} from’react-redux’;
import {ReduxRouter} from “redux-react-router”;
import {Route} from “react-router”

import createBrowserHistory from “history/lib/createBrowserHistory”< br />import configureStore from’./store’;

import routes from “./routes”;
import {fetchData} from’./actions/actions’;

const history = new createBrow serHistory();
const store = configureStore();

ReactDOM.render(





,
document.getElementById(‘root’)
);

routes.js

import React from "react";
import {Provider} from'react-redux ';
import {ReduxRouter} from "redux-react-router";
import {Route} from "react-router"


import App from ". /../containers/App";
import Home from "./../components/Home";
import Countries from "./../components/Countries";
< br />const router =





;

export default router ;

However, because the loadData function cannot be recognized, an error is thrown.

Please help.

Pass it as a child, please note that the parent is called a router:


{ routes}

There are no historical props for routing, routers.

Check the examples of Router.js and Route.js on my launcher: https ://github.com/DominicTobias/universal-react/tree/master/app

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 1317 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.