react-router

Having Issues trying to re-direct user based on state , using React-Router

不羁岁月 提交于 2021-01-28 11:41:08
问题 my app component redirects a used based if they are logged in = true, I used an online example after trying various methods, if there is a more simple functional react way to do it, please show me, If user is Logged in , I want them to go to /createpost else I want them to go to the /login route, I want to protect the /createpost route that user has to be logged in, but that is a task for another time, though ideas appreciated.. sandbox: https://codesandbox.io/s/focused-sammet-eitqr my app

React routing always loads the same component

时光毁灭记忆、已成空白 提交于 2021-01-28 11:09:43
问题 I am trying to add routing to my simple application: import Home from './componantes/Home' import Contact from './componantes/Contact' import Aboutus from './componantes/Aboutus' import { Route, Link, BrowserRouter as Router} from 'react-router-dom' const routing = ( <Router> <div> <Route path="/" component={Home} /> <Router path="/contact" component={Contact} /> <Router path ="/about" component={Aboutus} /> </div> </Router> ) ReactDOM.render(routing, document.getElementById('root')); but

React route - Content disappears on page refresh

試著忘記壹切 提交于 2021-01-28 09:27:29
问题 I want to use a sidebar when following links using React Route but when I refresh the page the content disappears Lesson.jsx import React from "react"; import { BrowserRouter as Router, Switch, Route, Link } from "react-router-dom"; import Home from "./components/Example"; import './css/activeLink.css' const routes = [ { path: "/", exact: true, sidebar: () => null, main: () => <h2>Home1</h2> }, { path: "/bubblegum", sidebar: () => null, main: () => <Home />, }, { path: "/shoelaces", sidebar:

React Router does not recognize direct address line changing in laravel

不羁岁月 提交于 2021-01-28 08:54:52
问题 I use React Router and Laravel. When I navigate throught Link elements all OK, but when I change browser address line to manually show another component Laravel shows it defalt 404 page. This is default web.php content, in welcome.blade.php I inlcude js/app.js file: Route::get('/', function () { return view('welcome'); }); This is my App.js content: import React from 'react'; import { Switch, Route } from "react-router-dom"; import Signin from "../../containers/Signin"; import Signup from "..

React Router does not recognize direct address line changing in laravel

我的未来我决定 提交于 2021-01-28 08:40:43
问题 I use React Router and Laravel. When I navigate throught Link elements all OK, but when I change browser address line to manually show another component Laravel shows it defalt 404 page. This is default web.php content, in welcome.blade.php I inlcude js/app.js file: Route::get('/', function () { return view('welcome'); }); This is my App.js content: import React from 'react'; import { Switch, Route } from "react-router-dom"; import Signin from "../../containers/Signin"; import Signup from "..

React Router in Azure IIS Rewrite

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-28 08:09:56
问题 I have a few routes in my React app that accept a GUID value as a parameter. For instance, a user receives an email with a link and follows that link to verify and activate their account on the site. <Route exact path="/register" component={Register} /> <Route path="/register/:id" component={RegistrationConfirmation} /> When I deploy this app to Azure, I am able to serve the page through express and navigate to http://[mysiteUrl]/register but static links provided in confirmation emails yield

React Router - How to redirect user if logged in?

人盡茶涼 提交于 2021-01-28 07:40:30
问题 I'm using react-router-dom to manage my routes: const Routes = () => { return ( <BrowserRouter> <div> <Route path="/" component={Navbar} /> <Switch> <Route exact path="/" component={Main} /> <Route path="/signin" component={SignIn} /> <Route path="/signup" component={SignUp} /> <PrivateRoute path="/dashboard" component={DashboardRoutes} /> <Route path="*" component={() => <h1>Page not found</h1>} /> </Switch> </div> <div> <Route path="/" component={Footer} /> </div> </BrowserRouter> ); }; I

React redux and React router,link change does not re render view [duplicate]

十年热恋 提交于 2021-01-28 07:29:38
问题 This question already has answers here : React router changes url but not view (22 answers) Closed 2 years ago . I a few <Link/> elements and a few corresponding components that are rendered via the <Route/> The components that are being rendered by <Route/> are redux connect -ed. On clicking the links,the url in the address bar changes but not the rendered component view. However,the proper view is rendered on refreshing. Code for the container component(the one with the Routers and Links)

React Router - How to redirect user if logged in?

倖福魔咒の 提交于 2021-01-28 07:21:00
问题 I'm using react-router-dom to manage my routes: const Routes = () => { return ( <BrowserRouter> <div> <Route path="/" component={Navbar} /> <Switch> <Route exact path="/" component={Main} /> <Route path="/signin" component={SignIn} /> <Route path="/signup" component={SignUp} /> <PrivateRoute path="/dashboard" component={DashboardRoutes} /> <Route path="*" component={() => <h1>Page not found</h1>} /> </Switch> </div> <div> <Route path="/" component={Footer} /> </div> </BrowserRouter> ); }; I

React Router - Path with :id is not working correctly for component wrapped by HOC

不问归期 提交于 2021-01-28 06:11:21
问题 Hi I have been developing this application using react and react-router-dom The Page component is wrapped by a HOC that imports a contentservice to access a rest api. My navigation is in the App component. The relevant part is the <Link to="/page/123">About Page</Link> and <Link to="/page/456">Contact Page</Link> When these links are clicked the page doesn't redraw as i expected. First time i go to 'About Page' it's all good. Then when i click to go to 'Contact Page' nothing changes. Then i