1- import React , { useState , useContext } from 'react'
1+ import React , { useState , useContext , useRef } from 'react'
22import axios , { AxiosRequestConfig } from 'axios' ;
33import * as settings from '../settings' ;
44
55import CssBaseline from '@material-ui/core/CssBaseline' ;
66import { makeStyles } from '@material-ui/core/styles' ;
77import { Container , Grid , Paper , Typography , Button , TextField , Tooltip , Switch , createStyles , Theme , withStyles , SwitchProps , SwitchClassKey } from '@material-ui/core' ;
8- import { AuthProps } from '../App' ;
8+ import { AppProps } from '../App' ;
99import { AlertContext } from '../contexts/AlertContext' ;
1010
1111const useStyles = makeStyles ( ( theme ) => ( {
@@ -104,12 +104,12 @@ const IOSSwitch = withStyles((theme: Theme) =>
104104} ) ;
105105
106106
107- function Home ( props : AuthProps ) {
107+ function Home ( props : AppProps ) {
108108
109109 const [ name , setName ] = useState ( "" )
110110 const [ helloName , setHelloName ] = useState ( "" )
111111 const [ token , setToken ] = useState ( props . token )
112-
112+ const userInput = useRef < HTMLInputElement > ( null )
113113 const { TriggerAlert } = useContext ( AlertContext )
114114 const classes = useStyles ( )
115115
@@ -153,8 +153,7 @@ function Home(props: AuthProps) {
153153 autoComplete = "name"
154154 autoFocus
155155 onChange = { handleFormFieldChange }
156- >
157- </ TextField >
156+ />
158157 < Tooltip title = { `Enter name and click submit to see a ${ token === props . token ? 'successful' : 'failed' } request.` } >
159158 < Button variant = "contained" color = "primary" onClick = { handleSubmit } disabled = { name . length === 0 } >
160159 Submit
@@ -173,7 +172,7 @@ function Home(props: AuthProps) {
173172 </ Paper >
174173 </ Grid >
175174 < Grid item xs = { 6 } >
176- < Paper className = { classes . title } >
175+ < Paper className = { classes . textInput } >
177176 < Typography variant = "h6" >
178177 Test Panel:
179178 </ Typography >
@@ -193,6 +192,20 @@ function Home(props: AuthProps) {
193192 < Grid item > On</ Grid >
194193 </ Grid >
195194 </ Typography >
195+ < Typography variant = "subtitle2" style = { { marginTop : 20 } } >
196+ Pass Param to Nested Subroute: < span > </ span >
197+ </ Typography >
198+ < TextField
199+ margin = "normal"
200+ fullWidth
201+ variant = "outlined"
202+ id = "userinput"
203+ label = "User Input"
204+ name = "User Input"
205+ inputRef = { userInput } />
206+ < Button variant = "contained" color = "primary" onClick = { ( ) => props . history . push ( `${ props . location . pathname } /nestedsubroute/${ userInput . current ?. value } ` ) } >
207+ Submit
208+ </ Button >
196209 </ Paper >
197210 </ Grid >
198211 </ Grid >
0 commit comments