@@ -301,6 +301,7 @@ type CombinedHintsEditorProps = {
301
301
*/
302
302
class CombinedHintsEditor extends React . Component < CombinedHintsEditorProps > {
303
303
static HintEditor : typeof HintEditor = HintEditor ;
304
+ hintEditors : Record < number , CombinedHintEditor | null > = { } ;
304
305
305
306
static defaultProps : {
306
307
highlightLint : boolean ;
@@ -353,9 +354,7 @@ class CombinedHintsEditor extends React.Component<CombinedHintsEditorProps> {
353
354
const hint = hints . splice ( i , 1 ) [ 0 ] ;
354
355
hints . splice ( i + dir , 0 , hint ) ;
355
356
this . props . onChange ( { hints : hints } , ( ) => {
356
- // eslint-disable-next-line react/no-string-refs
357
- // @ts -expect-error - TS2339 - Property 'focus' does not exist on type 'ReactInstance'.
358
- this . refs [ "hintEditor" + ( i + dir ) ] . focus ( ) ;
357
+ this . hintEditors [ i + dir ] ?. focus ( ) ;
359
358
} ) ;
360
359
} ;
361
360
@@ -365,42 +364,29 @@ class CombinedHintsEditor extends React.Component<CombinedHintsEditorProps> {
365
364
] ) ;
366
365
this . props . onChange ( { hints : hints } , ( ) => {
367
366
const i = hints . length - 1 ;
368
- // eslint-disable-next-line react/no-string-refs
369
- // @ts -expect-error - TS2339 - Property 'focus' does not exist on type 'ReactInstance'.
370
- this . refs [ "hintEditor" + i ] . focus ( ) ;
367
+ this . hintEditors [ i ] ?. focus ( ) ;
371
368
} ) ;
372
369
} ;
373
370
374
371
getSaveWarnings : ( ) => any = ( ) => {
375
- return _ . chain ( this . props . hints )
372
+ return this . props . hints
376
373
. map ( ( hint , i ) => {
377
- return _ . map (
378
- // eslint-disable-next-line react/no-string-refs
379
- // @ts -expect-error - TS2339 - Property 'getSaveWarnings' does not exist on type 'ReactInstance'.
380
- this . refs [ "hintEditor" + i ] . getSaveWarnings ( ) ,
381
- ( issue ) => "Hint " + ( i + 1 ) + ": " + issue ,
382
- ) ;
374
+ return this . hintEditors [ i ]
375
+ ?. getSaveWarnings ( )
376
+ . map ( ( issue ) => "Hint " + ( i + 1 ) + ": " + issue ) ;
383
377
} )
384
- . flatten ( true )
385
- . value ( ) ;
378
+ . flat ( ) ;
386
379
} ;
387
380
388
- serialize : ( options ?: any ) => ReadonlyArray < PerseusRenderer > = (
389
- options : any ,
390
- ) => {
381
+ serialize ( options ?: any ) : ReadonlyArray < PerseusRenderer > {
391
382
return this . props . hints . map ( ( hint , i ) => {
392
383
return this . serializeHint ( i , options ) ;
393
384
} ) ;
394
- } ;
385
+ }
395
386
396
- serializeHint : ( index : number , options ?: any ) => PerseusRenderer = (
397
- index ,
398
- options ,
399
- ) => {
400
- // eslint-disable-next-line react/no-string-refs
401
- // @ts -expect-error - TS2339 - Property 'serialize' does not exist on type 'ReactInstance'.
402
- return this . refs [ "hintEditor" + index ] . serialize ( options ) ;
403
- } ;
387
+ serializeHint ( index : number , options ?: any ) : PerseusRenderer {
388
+ return this . hintEditors [ index ] ! . serialize ( options ) ! ;
389
+ }
404
390
405
391
render ( ) : React . ReactNode {
406
392
const { itemId, hints} = this . props ;
@@ -409,7 +395,9 @@ class CombinedHintsEditor extends React.Component<CombinedHintsEditorProps> {
409
395
( hint , i ) => {
410
396
return (
411
397
< CombinedHintEditor
412
- ref = { "hintEditor" + i }
398
+ ref = { ( editor ) => {
399
+ this . hintEditors [ i ] = editor ;
400
+ } }
413
401
key = { "hintEditor" + i }
414
402
isFirst = { i === 0 }
415
403
isLast = { i + 1 === hints . length }
0 commit comments