react-router-v4

SPA refresh when assets have changed?

ぃ、小莉子 提交于 2020-06-16 06:20:29
问题 I have written an SPA which caches all its assets like bundle-1234.js which are required in the index.html . I'm wondering that when the bundle-1234.js is downloaded, cached and executed how does the app ever refresh when the bundle changed to bundle-9876.js ? I'm using react-router-dom do the routing of my SPA, so a route change is not a page refresh. Beware that the app will not be manually refreshed by the user. How do you tell a SPA to refesh its assets when the page doesn't refresh? 来源:

using same component for different route path in react-router v4

南楼画角 提交于 2020-06-09 11:42:28
问题 I am trying to have separate routes but same component for add/edit forms in my react app like the below: <Switch> <Route exact path="/dashboard" component={Dashboard}></Route> <Route exact path="/clients" component={Clients}></Route> <Route exact path="/add-client" component={manageClient}></Route> <Route exact path="/edit-client" component={manageClient}></Route> <Route component={ NotFound } /> </Switch> Now in the manageClient component, I parse the query params (I pass in a query string

How to fix the white screen after build with create-react-app?

巧了我就是萌 提交于 2020-06-08 17:14:39
问题 I used react-router-dom and I build my react-app. When I deploy it on the server, I get a blank page and the console is empty. My App.js is : import React, { Component } from 'react'; import { Route, Switch, BrowserRouter} from 'react-router-dom'; import Agenda from './components/Agenda/Agenda'; import Planning from './components/Planning/Planning'; class App extends Component { render() { return ( <div> <BrowserRouter basename="/"> <Switch> <Route exact path="/" component={Agenda} /> <Route

React-Router: Apply logic to component before navigating to a different route

允我心安 提交于 2020-05-26 06:05:01
问题 Is it possible to apply logic to a component before navigating to a different route? For example, my component looks something like this: class Example extends React.Component { //Handles logic for when user leaves page handlePageExit = () => { console.log("Leaving page..."); } //Set onBeforeUnload event listener so handlePageExit function is called when user closes or refreshes page componentDidMount = () => { window.addEventListener("onbeforeunload", this.handlePageExit); } //This hook is

React-Router - Route re-rendering component on route change

不想你离开。 提交于 2020-05-26 06:03:32
问题 Please read this properly before marking as duplicate, I assure you I've read and tried everything everyone suggests about this issue on stackoverflow and github. I have a route within my app rendered as below; <div> <Header compact={this.state.compact} impersonateUser={this.impersonateUser} users={users} organisations={this.props.organisations} user={user} logOut={this.logout} /> <div className="container"> {user && <Route path="/" component={() => <Routes userRole={user.Role} />} />} </div>

React-Router - Route re-rendering component on route change

血红的双手。 提交于 2020-05-26 06:00:18
问题 Please read this properly before marking as duplicate, I assure you I've read and tried everything everyone suggests about this issue on stackoverflow and github. I have a route within my app rendered as below; <div> <Header compact={this.state.compact} impersonateUser={this.impersonateUser} users={users} organisations={this.props.organisations} user={user} logOut={this.logout} /> <div className="container"> {user && <Route path="/" component={() => <Routes userRole={user.Role} />} />} </div>

React-Router - Route re-rendering component on route change

Deadly 提交于 2020-05-26 05:59:30
问题 Please read this properly before marking as duplicate, I assure you I've read and tried everything everyone suggests about this issue on stackoverflow and github. I have a route within my app rendered as below; <div> <Header compact={this.state.compact} impersonateUser={this.impersonateUser} users={users} organisations={this.props.organisations} user={user} logOut={this.logout} /> <div className="container"> {user && <Route path="/" component={() => <Routes userRole={user.Role} />} />} </div>

Reload component via <Link> in React Router

做~自己de王妃 提交于 2020-05-15 06:18:08
问题 I'm trying to implement a facebook-like homepage (i.e. a list of posts with comments). PostList is the component in charge of loading the post list (using fetch in its componentDidMount() ), itself being a child of the component HomePage . I have another component for the navigation bar called NavBar with a <Link> component (from react-router-dom ) to the route of my HomePage component ('/'). When I'm on any page other than '/', using the link works fine: the Router mounts HomePage , and then

Warning: You should not use <Route component> and <Route render> in the same route; <Route render> will be ignored

爷,独闯天下 提交于 2020-05-14 20:01:45
问题 Hello i try to protected route if is no auth but it is not work Warning: You should not use Route component and Route render in the same route; Route render will be ignored App.js import React, { Fragment, useEffect } from 'react'; import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'; import NavBar from './component/Layout/NavBar'; import Landing from './component/Layout/Landing'; import Login from '../src/component/Auth/Login'; import Register from '../src/component/Auth

React Routing works in locally but not Heroku

假如想象 提交于 2020-05-11 07:28:48
问题 My issue here is incredibly similar if not exactly the same as the one outlined in this issue. Unfortunately, I haven't been able to resolve it using the strategy it provides. So here are my own details: I am using Create React App , React Router 4 , Express , and Heroku and have followed the instructions here with regards to setting up a server with CRA. Locally, I am able to access routes such as myapp/about , yet after building and pushing to heroku, these 404. I can navigate to this route