Skip to content

Simplify routing logic #156

@0xferit

Description

@0xferit

From browse route:

 useEffect(() => {
    if (!params.chain) {
      navigate("/" + Object.keys(networkMap)[0] + "/");
    } else if (networkMap[params.chain]?.contractInstances && ethereumContext?.chainId != params.chain) {
      ethereumContext?.changeNetwork(params.chain);
    }
  });

From router logic:

<Route path=":chain/report/"element={networkMap?.[value.chainId]?.contractInstances || !value.chainId ? <Create /> : <EthereumProviderErrors />}/>

From navigation:

  const links = [{name:"Front Page", to: `${ethereumContext?.chainId || Object.keys(networkMap)[0]}/`},
    {name:"Report", to: `${ethereumContext?.chainId || Object.keys(networkMap)[0]}/report`},
    {name:"Account", to: `${ethereumContext?.chainId || Object.keys(networkMap)[0]}/account`},
    {name:"F.A.Q.", to: `faq/`},
    {name:"About", to: `about/`}];

There are too many hacks and the solutions seem far from intuitive. Simplify routing logic to reduce complexity and prevent potential bugs.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions