fix: use Select value instead of defaultValue

when defaultValue is used to pass the current value of Select, a warning
is produced in the console: "cannot update a component while rendering a
different component `Controller`". an unrelated issue
(https://github.com/shadcn-ui/ui/issues/1253) that suggested using the
value prop instead of defaultValue somehow fixed this problem
This commit is contained in:
2024-12-02 11:10:59 +00:00
parent a92f5e8189
commit 3acb85abaf
3 changed files with 42 additions and 24 deletions

View File

@@ -192,7 +192,7 @@ function NewWorkspaceForm({
render={({ field }) => (
<FormItem>
<FormLabel>Image for this workspace</FormLabel>
<Select onValueChange={field.onChange} defaultValue={field.value}>
<Select onValueChange={field.onChange} value={field.value}>
<FormControl>
<SelectTrigger>
<SelectValue placeholder="Select an image" />
@@ -217,7 +217,7 @@ function NewWorkspaceForm({
render={({ field }) => (
<FormItem>
<FormLabel>Docker runtime</FormLabel>
<Select onValueChange={field.onChange} defaultValue={field.value}>
<Select onValueChange={field.onChange} value={field.value}>
<FormControl>
<SelectTrigger>
<SelectValue placeholder="Select a Docker runtime" />