Archives : April-2017

I am having one simple project of React JS and I am deploying into OSE. Also I am using below dependencies in my project. “webpack”: “^2.2.0”, “webpack-dev-server”: “^1.14.1”, “react”: “^15.5.4”, “react-router-dom”: “^4.1.1” also I am running my project through below build script. “build”: “SET NODE_ENV=production && webpack-dev-server –host 0.0.0.0 –inline –history-api-fallback –content-base . ” Everything ..

Read more

I’ve just started learning React and got stuck at this error. Uncaught TypeError: Cannot read property ‘pathname’ of undefined at new Router Here is my code: var React = require(‘react’); var ReactDOM = require(‘react-dom’); var { Route, Router, IndexRoute } = require(‘react-router’); var hashHistory = require(‘react-router-redux’) var Main = require(‘./components/Main’); ReactDOM.render( <Router history={hashHistory}> <Route path=”/” ..

Read more

I’m not able to figure out how react router and express route working together. I have this app.get(‘*’, function(req, res) { res.sendFile(path.resolve(__dirname) + ‘/server/static/index.html’); }); // routes const apiRoutes = require(‘./server/routes/api’); app.use(‘/api’, apiRoutes); The problem is my api can’t use GET because it will redirect to index.html. If I remove the wildcard route, then react-router ..

Read more

Looking at this React Router Dom v4 example https://reacttraining.com/react-router/web/example/auth-workflow I see that PrivateRoute component destructures a rest prop like this const PrivateRoute = ({ component: Component, …rest }) => ( <Route {…rest} render={props => ( fakeAuth.isAuthenticated ? ( <Component {…props}/> ) : ( <Redirect to={{ pathname: ‘/login’, state: { from: props.location } }}/> ) )}/> ..

Read more

I’m working in a Meteor + React project that requires using react-router for server-side rendering (SSR). The current react-router version is v3 and I followed a tutorial about SSR here. The steps in summary are: Create a common routes file Include the routes file in client-side router // index.js import React from ‘react’ import { ..

Read more

I am relatively new to reacts and I’m trying to figure out how to get React router to work. I’ve got a super simple test app that looks like this: import React from ‘react’; import ReactDOM from ‘react-dom’; import {BrowserRouter as Router, Route, Switch, IndexRoute, Link} from ‘react-router-dom’; const Home = () => <h1><Link to= ..

Read more

I am using the next version of React Router, and it seems to be dropping params. I expect the redirect below to retain the value of channelId, but the to route uses the literal string “:channelId” in the path instead. <Switch> <Route exact path=”/” component={Landing} /> <Route path=”/channels/:channelId/modes/:modeId” component={Window} /> <Redirect from=”/channels/:channelId” to=”/channels/:channelId/modes/window” /> </Switch> ..

Read more