Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

142
Visualizações
React Page is Loading on Redirect but has no functionality unless I manually refresh

first-time poster here and I need some help. I have a simple react app with a main page and a members only section. To enter the members only section you need to connect your MetaMask wallet. I have added this functionality and it works but when the members only page appears in the browser, the scroll bar is missing and the link in the nav section to go back to the main page just makes the browser URL flash the localhost:3000/ then stays on localhost:3000/members. If I manually refresh the page my scrollbar appears and the page functions like it should. I don't understand what is going wrong and I am at my wits end trying to fix this.

App.js

import bootstrap from "bootstrap";
import MainPage from "./views/MainPage";
import Members from "./views/Members";
import "bootstrap/dist/css/bootstrap.min.css";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
import { Web3ReactProvider } from "@web3-react/core";

import Web3 from "web3";

function getLibrary(provider) {
  return new Web3(provider);
}

function App() {
  return (
    <Web3ReactProvider getLibrary={getLibrary}>
      <Router >
        <div className="">
          <Switch>
            <Route exact path="/members" component={Members} />
            <Route path="/" component={MainPage} />
          </Switch>
        </div>
      </Router>
    </Web3ReactProvider>
  );
}

export default App;

MemberCheck.js

import { useWeb3React } from "@web3-react/core";
import { useHistory,Redirect } from "react-router-dom";
import { injected } from "./wallet/Connect";

export default function MemberCheck() {
  const { active, account, library, connector, activate, deactivate } =
    useWeb3React();

  async function connect() {
    try {
      await activate(injected);
      console.log("connected");
    } catch (ex) {
      console.log(ex);
    }
  }

  let history = useHistory()


  return (
    <div>
      <li
        onClick={connect}

        className="nav-item memberCheck"
        style={{
          textDecoration: "none",
          color: "white",
          fontFamily: "scary",
          fontSize: "2rem",
        }}
      >
        MEMBERS ONLY
        {active ? history.push("/members") : <Redirect to="/" />}
      </li>
    </div>
  );
}

Thanks in advance!

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda