11import React , { useEffect } from 'react' ;
2- import { Helmet } from 'react-helmet' ;
3- import { Route , Switch } from 'react-router-dom' ;
2+ import Helmet from 'react-helmet' ;
3+ import { Route , Switch , RouteComponentProps } from 'react-router-dom' ;
44import MaxWidth from '@codesandbox/common/lib/components/flex/MaxWidth' ;
55import Margin from '@codesandbox/common/lib/components/spacing/Margin' ;
66import {
@@ -15,19 +15,9 @@ import Showcase from './Showcase';
1515import Sandboxes from './Sandboxes' ;
1616import { Container , Content } from './elements' ;
1717
18- interface IProfileProps {
19- match : {
20- params : { username : string } ;
21- url : string ;
22- } ;
23- }
18+ interface IProfileProps extends RouteComponentProps < { username : string } > { }
2419
25- const Profile : React . FC < IProfileProps > = ( {
26- match : {
27- params : { username } ,
28- url,
29- } ,
30- } ) => {
20+ export const Profile : React . FC < IProfileProps > = ( { match } ) => {
3121 const {
3222 state : {
3323 profile : { current : user , notFound } ,
@@ -36,6 +26,7 @@ const Profile: React.FC<IProfileProps> = ({
3626 profile : { profileMounted } ,
3727 } ,
3828 } = useOvermind ( ) ;
29+ const { username } = match . params ;
3930
4031 useEffect ( ( ) => {
4132 profileMounted ( { username } ) ;
@@ -45,9 +36,7 @@ const Profile: React.FC<IProfileProps> = ({
4536 return < NotFound /> ;
4637 }
4738
48- if ( ! user ) {
49- return < div /> ;
50- }
39+ if ( ! user ) return < div /> ;
5140
5241 return (
5342 < Container >
@@ -67,23 +56,25 @@ const Profile: React.FC<IProfileProps> = ({
6756 < MaxWidth width = { 1024 } >
6857 < Margin horizontal = { 2 } style = { { minHeight : '60vh' } } >
6958 < Switch >
70- < Route path = { url } exact render = { ( ) => < Showcase /> } />
59+ < Route path = { match . url } exact render = { ( ) => < Showcase /> } />
7160 < Route
7261 path = { `${ profileSandboxesUrl ( user . username ) } /:page?` }
73- render = { ( { match } ) => (
62+ // eslint-disable-next-line
63+ children = { ( { match : psMatch } ) => (
7464 < Sandboxes
7565 source = "currentSandboxes"
76- page = { match . params . page && + match . params . page }
66+ page = { psMatch . params . page && + psMatch . params . page }
7767 baseUrl = { profileSandboxesUrl ( user . username ) }
7868 />
7969 ) }
8070 />
8171 < Route
8272 path = { `${ profileLikesUrl ( user . username ) } /:page?` }
83- render = { ( { match } ) => (
73+ // eslint-disable-next-line
74+ children = { ( { match : plMatch } ) => (
8475 < Sandboxes
8576 source = "currentLikedSandboxes"
86- page = { match . params . page && + match . params . page }
77+ page = { plMatch . params . page && + plMatch . params . page }
8778 baseUrl = { profileLikesUrl ( user . username ) }
8879 />
8980 ) }
@@ -93,6 +84,4 @@ const Profile: React.FC<IProfileProps> = ({
9384 </ MaxWidth >
9485 </ Container >
9586 ) ;
96- } ;
97-
98- export default Profile ;
87+ } ;
0 commit comments