Archives : March-2017

In react-router v3, I’ve been using router.setRouteLeaveHook to check if a form has unsaved changes, and if so return false to prevent the transition. Then I would display a custom bootstrap modal dialog with 3 buttons: Save Changes, Discard Changes, and Stay Here. I can’t use react-router v4’s Prompt component to do this because it’s ..

Read more

I am new to ReactJs. This is my code: var React = require(‘react’); var ReactDOM = require(‘react-dom’); var {Route, Router, IndexRoute, hashHistory} = require(‘react-router’); var Main = require(‘Main’); ReactDOM.render( <Router history={hashHistory}> <Route path=”/” component={Main}></Route> </Router>, document.getElementById(‘app’)); and compiling it with webpack. Also I added Main component to my aliases. The console throws these errors: I ..

Read more

I keep on getting the error: A ‘Router’ may have only one child element when using react-router. I can’t seem to figure out why this is not working, since it’s exactly like the code they show in their example: Quick Start Here is my code: import React from ‘react’; import Editorstore from ‘./Editorstore’; import App ..

Read more

I develop a website with React/Redux and I use a thunk middleware to call my API. My problem concerns redirections after actions. I really do not know how and where I can do the redirection: in my action, in the reducer, in my component, … ? My action looks like this: export function deleteItem(id) { ..

Read more

This is common purpose, directing unmatch request to notfound page. making this with react-router v4 looks like previous versions and I expect this sample works below. Links work fine but I expect NotFound component called only unknown url requested; but its always there. import { BrowserRouter as Router, Route, Link } from ‘react-router-dom’ class Layout ..

Read more

Since I’m using react-router to handle my routes in a react app, I’m curious if there is a way to redirect to an external resource. Say someone hits: example.com/privacy-policy I would like it to redirect to: example.zendesk.com/hc/en-us/articles/123456789-Privacy-Policies I’m finding exactly zero help in avoiding writing it in plain JS at my index.html loading with something ..

Read more

I have the following setup: <div> <Router history={browserHistory}> <Route path=”/” component={NewCustomerContainer} /> <Route path=”/newCustomer” component={NewCustomerContainer} /> <Route path=”/search” component={SearchPageContainer} /> <Route path=”/network” component={NetworkContainer} /> <Route path=”/network/:id” component={NetworkContainer} ></Route> </Router> </div> The route http://localhost:8100/network works fine. The route http://localhost:8100/network/abc123 does not with a 404 error appearing in my console. Anyone seen anything like this before? Source: ..

Read more

I’ve been having some trouble with react router (i’m using version^4.0.0). this is my index.js import React from ‘react’; import ReactDOM from ‘react-dom’; import App from ‘./App’; import ‘./index.css’; import { Router, Route, Link, browserHistory } from ‘react-router’; ReactDOM.render( <Router history={browserHistory} > <Route path=”/” component={App} /> </Router>, document.getElementById(‘root’) ); the App.js is just anything. i’m ..

Read more