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