Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3 adds a simple router #3

Open
wants to merge 1 commit into
base: contract-calls
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"dependencies": {
"@openzeppelin/cli": "^2.8.2",
"@openzeppelin/contracts-ethereum-package": "^3.0.0",
"@reach/router": "^1.3.3",
"@web3-react/core": "^6.0.9",
"@web3-react/injected-connector": "^6.0.7",
"ethers": "^4.0.47",
Expand Down
7 changes: 6 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React from "react";
import { Router, Link } from "@reach/router";
import Layout from "./Layout";
import { Web3ReactProvider } from '@web3-react/core'

import Main from "./Main";
import IpfsPage from "./IpfsPage";
import Web3 from "web3";

const getLibrary = (provider: any): Web3 => {
Expand All @@ -12,7 +14,10 @@ const getLibrary = (provider: any): Web3 => {
const App: React.FC = () => (
<Web3ReactProvider getLibrary={getLibrary}>
<Layout>
<Main></Main>
<Router>
<Main path="/" />
<IpfsPage path="ipfs" />
</Router>
</Layout>
</Web3ReactProvider>
);
Expand Down
15 changes: 15 additions & 0 deletions src/IpfsPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from "react";


const IpfsPage: React.FC = () => {

return (
<div>
<p>
ipfs page
</p>
</div>
);
};

export default IpfsPage;
5 changes: 4 additions & 1 deletion src/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useEffect } from "react";
import { injected } from './connectors'
import { useWeb3React } from "@web3-react/core";
import Web3 from "web3";
import { Link } from "@reach/router";

const Layout: React.FC = ({ children }) => {
const context = useWeb3React<Web3>()
Expand All @@ -15,7 +16,9 @@ const Layout: React.FC = ({ children }) => {
<div>loading...</div>
) : (
<div>
<header>Demo</header>
<header>
Demo [<Link to="/">main</Link> | <Link to="/ipfs">ipfs</Link>]
</header>
<main>{children}</main>
</div>
);
Expand Down
Loading