Skip to content

Commit 15e6035

Browse files
authored
Fix UI warning about NaNs (#4142)
`e.target.valueAsNumber` converts empty strings to NaNs, but passing them to value attribute doesn't convert them back to empty strings. ``` ## Error Type Console Error ## Error Message Received NaN for the `value` attribute. If this is expected, cast the value to a string. at input (<anonymous>:null:null) at TextField (lib/TextField/TextField.tsx:25:5) at EditMirror (app/mirrors/[mirrorId]/edit/page.tsx:207:13) ## Code Frame 23 | } 24 | return ( > 25 | <BaseInputField | ^ 26 | {...(inputProps as ComponentProps<typeof BaseInputField>)} 27 | /> 28 | ); Next.js version: 16.1.6 (Webpack) ```
1 parent 4113fa6 commit 15e6035

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

ui/app/mirrors/[mirrorId]/edit/page.tsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ export default function EditMirror({ params }: EditMirrorProps) {
193193
batchSize: e.target.valueAsNumber,
194194
})
195195
}
196-
value={config.batchSize}
196+
value={Number.isNaN(config.batchSize) ? '' : config.batchSize}
197197
/>
198198
</div>
199199
}
@@ -213,7 +213,7 @@ export default function EditMirror({ params }: EditMirrorProps) {
213213
idleTimeout: e.target.valueAsNumber,
214214
})
215215
}
216-
value={config.idleTimeout}
216+
value={Number.isNaN(config.idleTimeout) ? '' : config.idleTimeout}
217217
/>
218218
</div>
219219
}
@@ -233,7 +233,11 @@ export default function EditMirror({ params }: EditMirrorProps) {
233233
snapshotNumRowsPerPartition: e.target.valueAsNumber,
234234
})
235235
}
236-
value={config.snapshotNumRowsPerPartition}
236+
value={
237+
Number.isNaN(config.snapshotNumRowsPerPartition)
238+
? ''
239+
: config.snapshotNumRowsPerPartition
240+
}
237241
/>
238242
</div>
239243
}
@@ -253,7 +257,11 @@ export default function EditMirror({ params }: EditMirrorProps) {
253257
snapshotMaxParallelWorkers: e.target.valueAsNumber,
254258
})
255259
}
256-
value={config.snapshotMaxParallelWorkers}
260+
value={
261+
Number.isNaN(config.snapshotMaxParallelWorkers)
262+
? ''
263+
: config.snapshotMaxParallelWorkers
264+
}
257265
/>
258266
</div>
259267
}
@@ -273,7 +281,11 @@ export default function EditMirror({ params }: EditMirrorProps) {
273281
snapshotNumTablesInParallel: e.target.valueAsNumber,
274282
})
275283
}
276-
value={config.snapshotNumTablesInParallel}
284+
value={
285+
Number.isNaN(config.snapshotNumTablesInParallel)
286+
? ''
287+
: config.snapshotNumTablesInParallel
288+
}
277289
/>
278290
</div>
279291
}

0 commit comments

Comments
 (0)