Skip to content

Commit

Permalink
make react-json-view dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
zurgl committed Nov 10, 2021
1 parent df4d707 commit 846d55d
Show file tree
Hide file tree
Showing 18 changed files with 222 additions and 443 deletions.
File renamed without changes.
5 changes: 3 additions & 2 deletions components/protocols/polygon/components/steps/Query.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import {PolygonQueryResponse} from '@figment-polygon/types';
import {LoadingOutlined} from '@ant-design/icons';
import {Alert, Button, Col, Space} from 'antd';
import {useState} from 'react';
import ReactJson from 'react-json-view';
import dynamic from 'next/dynamic';
const DynamicReactJson = dynamic(() => import('react-json-view'), {ssr: false});
import axios from 'axios';
import {
getCurrentChainId,
Expand Down Expand Up @@ -57,7 +58,7 @@ const Query = () => {
boxSizing: 'content-box',
}}
>
<ReactJson
<DynamicReactJson
src={queryData}
collapsed={false}
name={'query data'}
Expand Down
6 changes: 4 additions & 2 deletions components/protocols/solana/components/nav/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import {trackStorageCleared} from 'utils/tracking-utils';
import {Typography, Popover, Button, Select} from 'antd';
import type {EntryT, ErrorT} from '@figment-solana/types';
import ReactJson from 'react-json-view';
import dynamic from 'next/dynamic';
// import ReactJson from 'react-json-view';
const DynamicReactJson = dynamic(() => import('react-json-view'), {ssr: false});
import {StepMenuBar} from 'components/shared/Layout/StepMenuBar';
import {
getCurrentChainId,
Expand Down Expand Up @@ -127,7 +129,7 @@ const Nav = () => {

export const ErrorBox = ({error}: {error: ErrorT}) => {
return (
<ReactJson
<DynamicReactJson
src={error}
collapsed={false}
name={'error'}
Expand Down
3 changes: 3 additions & 0 deletions next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@
"@types/react-dom": "^17.0.8",
"@types/react-router-dom": "^5.1.7",
"@types/styled-components": "^5.1.10",
"lodash": "^4.17.21",
"avalanche": "3.7.0",
"antd": "^4.16.1",
"avalanche": "3.7.0",
"axios": "^0.21.1",
"bn.js": "^5.2.0",
"dids": "^2.4.0",
"ethereumjs-util": "^7.1.0",
"graphql": "^15.6.1",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21",
"lodash.unescape": "^4.0.1",
"mz": "^2.7.0",
"near-api-js": "^0.41.0",
"next": "11.0.1",
"next": "12",
"nextjs-progressbar": "^0.0.11",
"react": "17.0.2",
"react": "^17.0.2",
"react-confetti": "^6.0.1",
"react-dom": "17.0.2",
"react-dom": "^17.0.2",
"react-feather": "^2.0.9",
"react-json-view": "^1.21.3",
"react-markdown": "^7.0.1",
Expand Down
4 changes: 2 additions & 2 deletions pages/api/solana/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export default async function connect(
try {
const {network} = req.body;
const url = getNodeURL(network);
const connection = undefined;
const version = undefined;
const connection = new Connection(url, 'confirmed');
const version = await connection.getVersion();
res.status(200).json(version['solana-core']);
} catch (error) {
let errorMessage = error instanceof Error ? error.message : 'Unknown Error';
Expand Down
17 changes: 2 additions & 15 deletions pages/avalanche.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import Head from 'next/head';
import dynamic from 'next/dynamic';
import {CHAINS_CONFIG} from 'lib/constants';
import {CHAINS, ChainPropT} from 'types';
import {fetchMarkdownForChainId} from 'utils/markdown';
import {Spinner} from 'components/shared/Layout/Spinner';
import {colors} from 'utils/colors';

const dynOptions = {
loading: function spinner() {
return <Spinner color={colors.figmentYellow} />;
},
ssr: false,
};
import WithLayoutAvalanche from 'components/protocols/avalanche';

export async function getStaticProps() {
return {
Expand All @@ -24,10 +15,6 @@ export async function getStaticProps() {

const Avalanche = (props: ChainPropT) => {
const {chain, markdown} = props;
const DynChain = dynamic(
() => import('../components/protocols/avalanche'),
dynOptions,
);

return (
<>
Expand All @@ -36,7 +23,7 @@ const Avalanche = (props: ChainPropT) => {
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" />
</Head>
<DynChain chain={chain} markdown={markdown} />
<WithLayoutAvalanche chain={chain} markdown={markdown} />
</>
);
};
Expand Down
17 changes: 2 additions & 15 deletions pages/celo.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import Head from 'next/head';
import dynamic from 'next/dynamic';
import {CHAINS_CONFIG} from 'lib/constants';
import {CHAINS, ChainPropT} from 'types';
import {fetchMarkdownForChainId} from 'utils/markdown';
import {Spinner} from 'components/shared/Layout/Spinner';
import {colors} from 'utils/colors';

const dynOptions = {
loading: function spinner() {
return <Spinner color={colors.figmentYellow} />;
},
ssr: false,
};
import WithLayoutCelo from 'components/protocols/celo';

export async function getStaticProps() {
return {
Expand All @@ -24,10 +15,6 @@ export async function getStaticProps() {

const Celo = (props: ChainPropT) => {
const {chain, markdown} = props;
const DynChain = dynamic(
() => import('../components/protocols/celo'),
dynOptions,
);

return (
<>
Expand All @@ -36,7 +23,7 @@ const Celo = (props: ChainPropT) => {
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" />
</Head>
<DynChain chain={chain} markdown={markdown} />
<WithLayoutCelo chain={chain} markdown={markdown} />
</>
);
};
Expand Down
17 changes: 2 additions & 15 deletions pages/ceramic.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import Head from 'next/head';
import dynamic from 'next/dynamic';
import {CHAINS_CONFIG} from 'lib/constants';
import {CHAINS, ChainPropT} from 'types';
import {fetchMarkdownForChainId} from 'utils/markdown';
import {Spinner} from 'components/shared/Layout/Spinner';
import {colors} from 'utils/colors';

const dynOptions = {
loading: function spinner() {
return <Spinner color={colors.figmentYellow} />;
},
ssr: false,
};
import WithLayoutCeramic from 'components/protocols/ceramic';

export async function getStaticProps() {
return {
Expand All @@ -24,10 +15,6 @@ export async function getStaticProps() {

const Ceramic = (props: ChainPropT) => {
const {chain, markdown} = props;
const DynChain = dynamic(
() => import('../components/protocols/ceramic'),
dynOptions,
);

return (
<>
Expand All @@ -36,7 +23,7 @@ const Ceramic = (props: ChainPropT) => {
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" />
</Head>
<DynChain chain={chain} markdown={markdown} />
<WithLayoutCeramic chain={chain} markdown={markdown} />
</>
);
};
Expand Down
17 changes: 2 additions & 15 deletions pages/near.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import Head from 'next/head';
import dynamic from 'next/dynamic';
import {CHAINS_CONFIG} from 'lib/constants';
import {CHAINS, ChainPropT} from 'types';
import {fetchMarkdownForChainId} from 'utils/markdown';
import {Spinner} from 'components/shared/Layout/Spinner';
import {colors} from 'utils/colors';

const dynOptions = {
loading: function spinner() {
return <Spinner color={colors.figmentYellow} />;
},
ssr: false,
};
import WithLayoutNear from 'components/protocols/near';

export async function getStaticProps() {
return {
Expand All @@ -24,10 +15,6 @@ export async function getStaticProps() {

const Near = (props: ChainPropT) => {
const {chain, markdown} = props;
const DynChain = dynamic(
() => import('../components/protocols/near'),
dynOptions,
);

return (
<>
Expand All @@ -36,7 +23,7 @@ const Near = (props: ChainPropT) => {
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" />
</Head>
<DynChain chain={chain} markdown={markdown} />
<WithLayoutNear chain={chain} markdown={markdown} />
</>
);
};
Expand Down
17 changes: 2 additions & 15 deletions pages/polkadot.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import Head from 'next/head';
import dynamic from 'next/dynamic';
import {CHAINS_CONFIG} from 'lib/constants';
import {CHAINS, ChainPropT} from 'types';
import {fetchMarkdownForChainId} from 'utils/markdown';
import {Spinner} from 'components/shared/Layout/Spinner';
import {colors} from 'utils/colors';

const dynOptions = {
loading: function spinner() {
return <Spinner color={colors.figmentYellow} />;
},
ssr: false,
};
import WithLayoutPolkadot from 'components/protocols/polkadot';

export async function getStaticProps() {
return {
Expand All @@ -24,10 +15,6 @@ export async function getStaticProps() {

const Polkadot = (props: ChainPropT) => {
const {chain, markdown} = props;
const DynChain = dynamic(
() => import('../components/protocols/polkadot'),
dynOptions,
);

return (
<>
Expand All @@ -36,7 +23,7 @@ const Polkadot = (props: ChainPropT) => {
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" />
</Head>
<DynChain chain={chain} markdown={markdown} />
<WithLayoutPolkadot chain={chain} markdown={markdown} />
</>
);
};
Expand Down
17 changes: 2 additions & 15 deletions pages/polygon.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import Head from 'next/head';
import dynamic from 'next/dynamic';
import {CHAINS_CONFIG} from 'lib/constants';
import {CHAINS, ChainPropT} from 'types';
import {fetchMarkdownForChainId} from 'utils/markdown';
import {Spinner} from 'components/shared/Layout/Spinner';
import {colors} from 'utils/colors';

const dynOptions = {
loading: function spinner() {
return <Spinner color={colors.figmentYellow} />;
},
ssr: false,
};
import WithLayoutPolygon from 'components/protocols/polygon';

export async function getStaticProps() {
return {
Expand All @@ -24,10 +15,6 @@ export async function getStaticProps() {

const Polygon = (props: ChainPropT) => {
const {chain, markdown} = props;
const DynChain = dynamic(
() => import('../components/protocols/polygon'),
dynOptions,
);

return (
<>
Expand All @@ -36,7 +23,7 @@ const Polygon = (props: ChainPropT) => {
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" />
</Head>
<DynChain chain={chain} markdown={markdown} />
<WithLayoutPolygon chain={chain} markdown={markdown} />
</>
);
};
Expand Down
17 changes: 2 additions & 15 deletions pages/secret.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import Head from 'next/head';
import dynamic from 'next/dynamic';
import {CHAINS_CONFIG} from 'lib/constants';
import {CHAINS, ChainPropT} from 'types';
import {fetchMarkdownForChainId} from 'utils/markdown';
import {Spinner} from 'components/shared/Layout/Spinner';
import {colors} from 'utils/colors';

const dynOptions = {
loading: function spinner() {
return <Spinner color={colors.figmentYellow} />;
},
ssr: false,
};
import WithLayoutSecret from 'components/protocols/secret';

export async function getStaticProps() {
return {
Expand All @@ -24,10 +15,6 @@ export async function getStaticProps() {

const Secret = (props: ChainPropT) => {
const {chain, markdown} = props;
const DynChain = dynamic(
() => import('../components/protocols/secret'),
dynOptions,
);

return (
<>
Expand All @@ -36,7 +23,7 @@ const Secret = (props: ChainPropT) => {
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" />
</Head>
<DynChain chain={chain} markdown={markdown} />
<WithLayoutSecret chain={chain} markdown={markdown} />
</>
);
};
Expand Down
17 changes: 2 additions & 15 deletions pages/solana.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import Head from 'next/head';
import dynamic from 'next/dynamic';
import {CHAINS_CONFIG} from 'lib/constants';
import {CHAINS, ChainPropT} from 'types';
import {fetchMarkdownForChainId} from 'utils/markdown';
import {Spinner} from 'components/shared/Layout/Spinner';
import {colors} from 'utils/colors';

const dynOptions = {
loading: function spinner() {
return <Spinner color={colors.figmentYellow} />;
},
ssr: false,
};
import WithLayoutSolana from 'components/protocols/solana';

export async function getStaticProps() {
return {
Expand All @@ -24,10 +15,6 @@ export async function getStaticProps() {

const Solana = (props: ChainPropT) => {
const {chain, markdown} = props;
const DynChain = dynamic(
() => import('../components/protocols/solana'),
dynOptions,
);

return (
<>
Expand All @@ -36,7 +23,7 @@ const Solana = (props: ChainPropT) => {
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" />
</Head>
<DynChain chain={chain} markdown={markdown} />
<WithLayoutSolana chain={chain} markdown={markdown} />
</>
);
};
Expand Down
Loading

0 comments on commit 846d55d

Please sign in to comment.