File tree 5 files changed +17
-43
lines changed
election-manager/src/components
5 files changed +17
-43
lines changed Original file line number Diff line number Diff line change 1
1
import React , { useEffect , useRef } from 'react' ;
2
- import { RouteComponentProps , withRouter } from 'react-router-dom' ;
2
+ import { useLocation } from 'react-router-dom' ;
3
3
import styled from 'styled-components' ;
4
4
import { ScreenReader } from '../utils/ScreenReader' ;
5
5
@@ -10,7 +10,7 @@ const StyledFocusManager = styled.div`
10
10
}
11
11
` ;
12
12
13
- export interface Props extends RouteComponentProps {
13
+ export interface Props {
14
14
children : React . ReactNode ;
15
15
onClick ?: React . DOMAttributes < HTMLElement > [ 'onClick' ] ;
16
16
onClickCapture ?: React . DOMAttributes < HTMLElement > [ 'onClickCapture' ] ;
@@ -21,7 +21,7 @@ export interface Props extends RouteComponentProps {
21
21
screenReader : ScreenReader ;
22
22
}
23
23
24
- function FocusManager ( {
24
+ export default function FocusManager ( {
25
25
onKeyPress,
26
26
onClick,
27
27
onFocus,
@@ -30,8 +30,8 @@ function FocusManager({
30
30
onFocusCapture,
31
31
children,
32
32
screenReader,
33
- location,
34
33
} : Props ) : JSX . Element {
34
+ const location = useLocation ( ) ;
35
35
const screen = useRef < HTMLDivElement > ( null ) ;
36
36
useEffect ( ( ) => {
37
37
function onPageLoad ( ) {
@@ -67,5 +67,3 @@ function FocusManager({
67
67
</ StyledFocusManager >
68
68
) ;
69
69
}
70
-
71
- export default withRouter ( FocusManager ) ;
Original file line number Diff line number Diff line change 1
1
import { strict as assert } from 'assert' ;
2
2
import React , { useContext , useEffect , useRef } from 'react' ;
3
3
import styled from 'styled-components' ;
4
- import { RouteComponentProps , withRouter } from 'react-router-dom' ;
4
+ import { useHistory } from 'react-router-dom' ;
5
5
import { getPartyPrimaryAdjectiveFromBallotStyle } from '@votingworks/types' ;
6
6
import { LinkButton , Main , MainChild } from '@votingworks/ui' ;
7
7
@@ -19,9 +19,8 @@ const SidebarSpacer = styled.div`
19
19
height: 90px;
20
20
` ;
21
21
22
- type Props = RouteComponentProps < Record < string , string | undefined > > ;
23
-
24
- function StartPage ( { history } : Props ) : JSX . Element {
22
+ export default function StartPage ( ) : JSX . Element {
23
+ const history = useHistory ( ) ;
25
24
const {
26
25
ballotStyleId,
27
26
contests,
@@ -121,5 +120,3 @@ function StartPage({ history }: Props): JSX.Element {
121
120
</ Screen >
122
121
) ;
123
122
}
124
-
125
- export default withRouter ( StartPage ) ;
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
- import { RouteComponentProps , withRouter } from 'react-router-dom' ;
2
+ import { useHistory } from 'react-router-dom' ;
3
3
import { EventTargetFunction } from '../config/types' ;
4
4
5
5
import Button , { ButtonInterface } from './Button' ;
6
6
7
7
interface Props
8
8
extends ButtonInterface ,
9
- // eslint-disable-next-line @typescript-eslint/ban-types
10
- RouteComponentProps < { } > ,
11
9
React . PropsWithoutRef < JSX . IntrinsicElements [ 'button' ] > { }
12
10
13
11
interface Props {
@@ -17,14 +15,11 @@ interface Props {
17
15
to ?: string ;
18
16
}
19
17
20
- function LinkButton ( props : Props ) {
18
+ export default function LinkButton ( props : Props ) : JSX . Element {
19
+ const history = useHistory ( ) ;
21
20
const {
22
21
goBack,
23
- history,
24
- location, // eslint-disable-line @typescript-eslint/no-unused-vars
25
- match, // eslint-disable-line @typescript-eslint/no-unused-vars
26
22
onPress,
27
- staticContext, // eslint-disable-line @typescript-eslint/no-unused-vars
28
23
to,
29
24
// ⬆ filtering out props which are not intrinsic to `<button>` element.
30
25
...rest
@@ -47,5 +42,3 @@ function LinkButton(props: Props) {
47
42
/>
48
43
) ;
49
44
}
50
-
51
- export default withRouter ( LinkButton ) ;
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
- import { RouteComponentProps , withRouter } from 'react-router-dom' ;
2
+ import { useHistory } from 'react-router-dom' ;
3
3
import { EventTargetFunction } from '../config/types' ;
4
4
5
5
import Button , { ButtonInterface } from './Button' ;
6
6
7
7
interface Props
8
8
extends ButtonInterface ,
9
- // eslint-disable-next-line @typescript-eslint/ban-types
10
- RouteComponentProps < { } > ,
11
9
React . PropsWithoutRef < JSX . IntrinsicElements [ 'button' ] > {
12
10
goBack ?: boolean ;
13
11
onPress ?: EventTargetFunction ;
14
12
primary ?: boolean ;
15
13
to ?: string ;
16
14
}
17
15
18
- function LinkButton ( props : Props ) {
16
+ export default function LinkButton ( props : Props ) : JSX . Element {
19
17
const {
20
18
goBack,
21
- history,
22
- location, // eslint-disable-line @typescript-eslint/no-unused-vars
23
- match, // eslint-disable-line @typescript-eslint/no-unused-vars
24
19
onPress,
25
- staticContext, // eslint-disable-line @typescript-eslint/no-unused-vars
26
20
to,
27
21
// ⬆ filtering out props which are not intrinsic to `<button>` element.
28
22
...rest
29
23
} = props ;
24
+ const history = useHistory ( ) ;
30
25
const handleOnPress : EventTargetFunction = ( event ) => {
31
26
/* istanbul ignore else */
32
27
if ( onPress ) {
@@ -45,5 +40,3 @@ function LinkButton(props: Props) {
45
40
/>
46
41
) ;
47
42
}
48
-
49
- export default withRouter ( LinkButton ) ;
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
- import { RouteComponentProps , withRouter } from 'react-router-dom' ;
2
+ import { useHistory } from 'react-router-dom' ;
3
3
import { EventTargetFunction } from '@votingworks/types' ;
4
4
import { Button , ButtonProps } from './Button' ;
5
5
6
- export interface LinkButtonProps
7
- extends Omit < ButtonProps , 'onPress' > ,
8
- RouteComponentProps < Record < string , string | undefined > > {
6
+ export interface LinkButtonProps extends Omit < ButtonProps , 'onPress' > {
9
7
goBack ?: boolean ;
10
8
onPress ?: EventTargetFunction ;
11
9
primary ?: boolean ;
12
10
to ?: string ;
13
11
}
14
12
15
- function LinkButton ( props : LinkButtonProps ) : JSX . Element {
13
+ export default function LinkButton ( props : LinkButtonProps ) : JSX . Element {
14
+ const history = useHistory ( ) ;
16
15
const {
17
16
goBack,
18
- history,
19
- location, // eslint-disable-line @typescript-eslint/no-unused-vars
20
- match, // eslint-disable-line @typescript-eslint/no-unused-vars
21
17
onPress,
22
- staticContext, // eslint-disable-line @typescript-eslint/no-unused-vars
23
18
to,
24
19
// ⬆ filtering out props which are not intrinsic to `<button>` element.
25
20
...rest
@@ -42,5 +37,3 @@ function LinkButton(props: LinkButtonProps): JSX.Element {
42
37
/>
43
38
) ;
44
39
}
45
-
46
- export default withRouter ( LinkButton ) ;
You can’t perform that action at this time.
0 commit comments