I am trying to create signup pages in react website but it's not working

Ganesh

I am trying to create a signup and sign in new site that's a react site.

I added components navbar/header in that header. I added a login button.

login button

and the link is working after clicking the link, the page is opening

login page url

The page's content is not showing. I added css also for content but it's not showing.

ChatGPT is giving answers but my compiler is showing errors. Can anyone of you help me to create this?

I am expecting a signup and login feature website.

This is my app.js code

import React from "react";
import { BrowserRouter } from 'react-router-dom';
import Header from "./components/layout/Header";

function App() {
  return(
    
    <Header />
    
  );
}
export default App;

This is my Header.js code:

import { Link } from "react-router-dom";
import { useState } from "react";
import Login from "../pages/Login";

function Header() {
    const [nav, setNav] = useState(false);

    const openNav = () => {
        setNav(!nav);
    }
    return (
      <div className="header-container">
        <div className="left-header">
          <h2 className="header">Fallen</h2>
        </div>
        <div className="right-header">
          <Link onClick={openNav} to="/Login">SignUp/Login</Link>
        </div>
      </div>
    );
  }
  
  export default Header;

This is my login js code:

function Login() {
    return(
        <>
        <h2>Login</h2>
        </>
    );
}
export default Login;

This is my index.js file:

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import { BrowserRouter } from 'react-router-dom';

ReactDOM.render(
  <React.StrictMode>
    <BrowserRouter>
      <App />
    </BrowserRouter>
  </React.StrictMode>,
  document.getElementById('root')
);

reportWebVitals();
myrn

You have not defined routes. After importing Routes and Route you should do:

import React from "react";
import { Routes, Route } from 'react-router-dom';
import Header from "./components/layout/Header";

function App() {
  return(
    <div className="App">
      <Routes>
        <Route path="login" element={<Login />} />
        <Route path="register" element={<Register />} />
        .
        . 
        .
      </Routes>
    </div>  
  );
}
export default App;

NOTE: I didn't add the Header because you can add it according to your scenario.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Partial keyword match not working when I am trying to create a new column from a pandas data frame in python?

I am trying to capture the login post data of a website but it's not showing up in the debugger

I am trying to make my regex work in MySQL but it's not working

I am trying to create a dynamic spinner

I am trying to create a simple angularjs project but the ng-view is not working

I am Trying to create a webview activity but the whole website is not loaded

I am trying to run yargs command, and it is not working

I am trying to create a rect element within a svg element, but its not working

I am new to python and i am trying to create a leaderboard

I am trying to run this react native screen where it fetches data for me. This gets run when i click the text from a home screen. But it's not working

I am trying to create a Login website by Connecting Database to Registration Page

I am trying to check for undefined but it's not working

I am trying to get images from other website but code is not working

I am trying to create a Clamp method in java

I am trying to create a javascript page to enter information into a form and it's not working

I am trying to create a simple search, on click of a search button it should redirect to new component .but redirect is not at all working?

I am trying to create a seven segment scoreboard

I am trying to create a box in React, and it is not working

I am trying to highlight the output with mark tag but it's not working

I am trying to create a calculator using react hooks. I was trying to get the current number and send it to the displayInput

I am trying to create a map figure in python using Plotly but my data is not being imported or it is not properly working

I am trying to use the react hook useContext() but its not working

I am trying to get the average of the numbers in an array in javascript but it's not working how I want to

I am trying to render data from mongodb server to react app. And it's not working

I am trying to navigate through the pages of a website and scrape its links but the same page data is scraped even after changing page number

I am trying to create a table with sqlite in Kotlin

I am trying to create a subscription but an error occurs

I am trying to create a flight widget

I am trying to add icons in my react app but this method not working Need help and guidance