@@ -7,7 +7,11 @@ import TextField from '@material-ui/core/TextField';
7
7
import Button from '@material-ui/core/Button' ;
8
8
import Select from '@material-ui/core/Select' ;
9
9
import InputLabel from '@material-ui/core/InputLabel' ;
10
- import { addProp , changeComponentFocusChild , deleteProp } from '../../actions/actionCreators' ;
10
+ import {
11
+ addProp ,
12
+ changeComponentFocusChild ,
13
+ deleteProp
14
+ } from '../../actions/actionCreators' ;
11
15
import DataTable from './DataTable' ;
12
16
import { PropInt , PropsInt } from '../../interfaces/Interfaces' ;
13
17
@@ -147,7 +151,7 @@ const mapDispatchToProps = (dispatch: any) => ({
147
151
} : {
148
152
componentId : number ;
149
153
childId : number ;
150
- } ) => dispatch ( changeComponentFocusChild ( { componentId, childId } ) ) ,
154
+ } ) => dispatch ( changeComponentFocusChild ( { componentId, childId } ) )
151
155
} ) ;
152
156
153
157
const mapStateToProps = ( store : any ) => ( {
@@ -198,8 +202,12 @@ class Props extends Component<PropsPropsInt, StateInt> {
198
202
}
199
203
200
204
// using useState to locally check a clickedValue
201
-
202
- handleChange = ( event : any ) => {
205
+ // React.ChangeEvent<HTML...Element> is the correct typing for events
206
+ handleChange = (
207
+ event :
208
+ | React . ChangeEvent < HTMLInputElement >
209
+ | React . ChangeEvent < HTMLSelectElement >
210
+ ) => {
203
211
if ( event . target . id === 'propVariable' ) {
204
212
this . setState ( {
205
213
[ event . target . id ] : event . target . value . trim ( )
@@ -251,15 +259,16 @@ class Props extends Component<PropsPropsInt, StateInt> {
251
259
type : propType
252
260
} ) ;
253
261
254
- this . props . changeComponentFocusChild ( { componentId : this . props . focusComponent . id , childId : this . props . focusChild . childId } ) ;
262
+ this . props . changeComponentFocusChild ( {
263
+ componentId : this . props . focusComponent . id ,
264
+ childId : this . props . focusChild . childId
265
+ } ) ;
255
266
this . setState ( {
256
267
propVariable : '' ,
257
268
propValue : '' ,
258
269
propRequired : true ,
259
270
propType : ''
260
271
} ) ;
261
-
262
-
263
272
} ;
264
273
265
274
render ( ) {
@@ -312,19 +321,28 @@ class Props extends Component<PropsPropsInt, StateInt> {
312
321
>
313
322
< Grid container spacing = { 8 } >
314
323
< Grid item xs = { 3 } >
315
- < form className = "props-input" onSubmit = { this . handleAddProp } >
324
+ < form
325
+ className = "props-input"
326
+ // JZ: assigned typing to onSubmit event, matches handleAddProp func
327
+ onSubmit = { ( event : React . ChangeEvent < HTMLFormElement > ) =>
328
+ this . handleAddProp ( event )
329
+ }
330
+ >
316
331
< Grid container spacing = { 8 } >
317
332
< Grid item xs = { 6 } >
318
333
< FormControl >
319
334
< TextField
320
335
type = "text"
321
- native
336
+ // native commented out due to overload error with material
322
337
id = "propVariable"
323
338
label = "Prop"
324
339
margin = "none"
325
340
autoFocus
326
341
size = "medium"
327
- onChange = { this . handleChange }
342
+ onChange = { (
343
+ //JZ: assigned typing to incoming event
344
+ event : React . ChangeEvent < HTMLInputElement >
345
+ ) => this . handleChange ( event ) }
328
346
value = { this . state . propVariable }
329
347
color = { 'primary' }
330
348
required
0 commit comments