Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to navigate to different page on click in react

import React from 'react';
import { useNavigate } from "react-router-dom";
function LoginLayout() {
  
  let navigate = useNavigate(); 
  const routeChange = () =>{ 
    let path = `newPath`; 
    navigate(path);
  }
  
  return (
     <div className="app flex-row align-items-center">
      <Container>
      ...          
          <Button color="primary" className="px-4"
            onClick={routeChange}
              >
              Login
            </Button>
      ...
       </Container>
    </div>
  );
}}
Comment

how to go to another page onclick in react

<Link to="/signup" className="btn btn-primary">Sign up</Link>
Comment

how to redirect to another page in react js on button click

import React from "react";
// importing Link from react-router-dom to navigate to 
// different end points.
import { Link } from "react-router-dom";
  
const Home = () => {
  return (
    <div>
      <h1>Home Page</h1>
      <br />
      <ul>
        <li>
          {/* Endpoint to route to Home component */}
          <Link to="/">Home</Link>
        </li>
        <li>
          {/* Endpoint to route to About component */}
          <Link to="/about">About</Link>
        </li>
        <li>
          {/* Endpoint to route to Contact Us component */}
          <Link to="/contactus">Contact Us</Link>
        </li>
      </ul>
    </div>
  );
};
  
export default Home;
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript throw error inside then 
Javascript :: javascript tostring method 
Javascript :: run function once javascript 
Javascript :: jquery equivalent of document.getelementbyid 
Javascript :: vue js cdn 
Javascript :: javascript change background color setinterval 
Javascript :: this setstate previous state react 
Javascript :: double click in js 
Javascript :: js bubble sort 
Javascript :: hover material ui styles 
Javascript :: cypress check element have attribute 
Javascript :: number to array js 
Javascript :: Summernote keyup event jquery 
Javascript :: javascript promise all 
Javascript :: javascript ready state 
Javascript :: response.json() promise pending 
Javascript :: math.min 
Javascript :: javascript backwards loop array 
Javascript :: how to submit form on changed url in function in jquery 
Javascript :: adding cypress to react project using npm 
Javascript :: add toaster in angular 
Javascript :: Next js window is not defined solution 
Javascript :: switch alert 
Javascript :: namespace in javascript 
Javascript :: set localstorage 
Javascript :: react native safeareaview 
Javascript :: javascript array delete first element 
Javascript :: get only numbers from string 
Javascript :: how to parse json in sql server 
Javascript :: radio button getelementsbyname 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =