Skip to content

Commit

Permalink
feat: change routing to react router
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasbenary committed Dec 30, 2024
1 parent 675ea01 commit 4e50be7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
5 changes: 2 additions & 3 deletions templates/frontend/vite-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
"near-api-js": "^4.0.3",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"wagmi": "^2.14.4",
"wouter": "^3.3.5"
"react-router": "^7.1.1"
},
"devDependencies": {
"@eslint/js": "^9.17.0",
Expand All @@ -50,4 +49,4 @@
"vite": "^6.0.3",
"vite-plugin-eslint": "^1.8.1"
}
}
}
13 changes: 9 additions & 4 deletions templates/frontend/vite-react/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Navigation } from './components/navigation';
import Home from './pages/home';
import { Route } from 'wouter';

import HelloNear from './pages/hello_near';
import { useEffect, useState } from 'react';
import { NetworkId } from './config.js';
import { NearContext, Wallet } from '@/wallets/near';
import { BrowserRouter, Routes, Route } from "react-router";

// Wallet instance
const wallet = new Wallet({ NetworkId: NetworkId });
Expand All @@ -21,9 +22,13 @@ function App() {

return (
<NearContext.Provider value={{ wallet, signedAccountId }}>
<Navigation />
<Route path="/" component={Home} />
<Route path="/hello-near" component={HelloNear}/>
<BrowserRouter>
<Navigation />
<Routes>
<Route path="/" element={<Home />} />
<Route path="/hello-near" element={<HelloNear />} />
</Routes>
</BrowserRouter>
</NearContext.Provider>
)
}
Expand Down
5 changes: 3 additions & 2 deletions templates/frontend/vite-react/src/components/cards.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import styles from '@/styles/app.module.css';
import { Link } from 'react-router';

export const Cards = () => {
return (
Expand All @@ -15,12 +16,12 @@ export const Cards = () => {
<p>Learn how this application works, and what you can build on Near.</p>
</a>

<a href="/hello-near" className={styles.card} rel="noopener noreferrer">
<Link to="/hello-near" className={styles.card} rel="noopener noreferrer">
<h2>
Near Integration <span>-&gt;</span>
</h2>
<p>Discover how simple it is to interact with a Near smart contract.</p>
</a>
</Link>
</div>
);
};
4 changes: 2 additions & 2 deletions templates/frontend/vite-react/src/components/navigation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useContext,useEffect, useState } from 'react';

import NearLogo from '@/assets/near-logo.svg';
import { NearContext } from '@/wallets/near';
import { Link } from 'wouter';
import { Link } from "react-router";
import styles from '@/styles/app.module.css';

export const Navigation = () => {
Expand All @@ -25,7 +25,7 @@ export const Navigation = () => {
return (
<nav className="navbar navbar-expand-lg">
<div className="container-fluid">
<Link href="/">
<Link to="/">
<img src={NearLogo} alt="NEAR" width="30" height="24" className={styles.logo} />
</Link>
<div className="navbar-nav pt-1">
Expand Down

0 comments on commit 4e50be7

Please sign in to comment.