nav2 push 2 history with userId
This commit is contained in:
parent
b631206c44
commit
22a76efc1f
@ -12,7 +12,7 @@ module.exports = {
|
||||
"nav1.main": "/nav1",
|
||||
"link.nav1.about": "/",
|
||||
"link.nav1.profile": "/my-best-profile-page-ever/:userId/:projectId",
|
||||
"nav2.main": "/nav2",
|
||||
'link.nav1.to.nav2.profile': '/by/:userId'
|
||||
},
|
||||
features: {
|
||||
"nav1": {
|
||||
|
10
src/app.tsx
10
src/app.tsx
@ -1,12 +1,12 @@
|
||||
import React from 'react';
|
||||
import { BrowserRouter, HashRouter } from 'react-router-dom';
|
||||
import { ThemeProvider } from '@emotion/react'
|
||||
import React from "react";
|
||||
import { BrowserRouter, HashRouter } from "react-router-dom";
|
||||
import { ThemeProvider } from "@emotion/react";
|
||||
|
||||
import { Dashboard } from './dashboard';
|
||||
import { Dashboard } from "./dashboard";
|
||||
|
||||
const App = () => {
|
||||
return (
|
||||
<ThemeProvider theme={{ colors: { main: 'green' } }}>
|
||||
<ThemeProvider theme={{ colors: { main: "green" } }}>
|
||||
<BrowserRouter>
|
||||
<Dashboard />
|
||||
</BrowserRouter>
|
||||
|
@ -9,10 +9,6 @@ export const StyledHeader = styled(Header)`
|
||||
export const Wrapper = styled.div<{ red?: boolean }>`
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
background-color: ${(props) => props.red ? 'red' : props.theme.colors.main};
|
||||
|
||||
${StyledHeader.toString()} {
|
||||
color: palevioletred;
|
||||
}
|
||||
background-color: ${(props) => props.red ? 'red' : props.theme.colors?.main};
|
||||
`;
|
||||
|
||||
|
@ -1,16 +1,17 @@
|
||||
import React from "react";
|
||||
import { Link, useParams } from "react-router-dom";
|
||||
import { generatePath, Link, useParams } from "react-router-dom";
|
||||
import { getHistory } from '@brojs/cli'
|
||||
import { getNavigationsValue } from "@brojs/cli";
|
||||
|
||||
import { URLs } from "../../__data__/urls";
|
||||
|
||||
const history = getHistory();
|
||||
const nav2ByUrl = getNavigationsValue('link.nav1.to.nav2.profile')
|
||||
|
||||
export const ProfilePage = () => {
|
||||
const handletoNav2Click = (event) => {
|
||||
event.preventDefault()
|
||||
history.push(getNavigationsValue('nav2.main'));
|
||||
history.push(generatePath(nav2ByUrl, { userId: 'some-user-id' }));
|
||||
}
|
||||
|
||||
const params = useParams<{ userId: string, prodileId: string }>();
|
||||
@ -21,7 +22,7 @@ export const ProfilePage = () => {
|
||||
<Link to={URLs.about.getUrl()}>go to about page</Link>
|
||||
|
||||
<div>
|
||||
<a onClick={handletoNav2Click} href={getNavigationsValue('nav2.main')}>edit profile</a>
|
||||
<a onClick={handletoNav2Click} href={generatePath(nav2ByUrl, { userId: 'some-user-id' })}>edit my profile</a>
|
||||
</div>
|
||||
|
||||
<pre>{JSON.stringify(params as Required<typeof params>, null, 4)}</pre>
|
||||
|
@ -12,7 +12,7 @@
|
||||
"moduleResolution": "node",
|
||||
"target": "es6",
|
||||
"jsx": "react",
|
||||
"typeRoots": ["node_modules/@types", "src/typings"],
|
||||
"typeRoots": ["node_modules/@types", "src/typings", "./types"],
|
||||
"types" : ["webpack-env", "node"],
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user