mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-20 13:22:07 +03:00
Merge pull request #5092 from urbit/lf/no-wipe-input
CommentInput: stop recreating input
This commit is contained in:
commit
1bf852fe91
@ -11,7 +11,7 @@ import {
|
|||||||
useField,
|
useField,
|
||||||
useFormikContext
|
useFormikContext
|
||||||
} from 'formik';
|
} from 'formik';
|
||||||
import React, { useEffect } from 'react';
|
import React, { useEffect, useMemo } from 'react';
|
||||||
import * as Yup from 'yup';
|
import * as Yup from 'yup';
|
||||||
import { ShipImage } from './ShipImage';
|
import { ShipImage } from './ShipImage';
|
||||||
|
|
||||||
@ -68,9 +68,13 @@ function FormikHelper(props: { initialValues: any }) {
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
const emptyStr = '';
|
||||||
|
|
||||||
export default function CommentInput(props: CommentInputProps) {
|
export default function CommentInput(props: CommentInputProps) {
|
||||||
const initialValues: FormSchema = { comment: props.initial || '' };
|
const initialValues: FormSchema = useMemo(
|
||||||
|
() => ({ comment: props.initial || emptyStr }),
|
||||||
|
[props.initial]);
|
||||||
|
|
||||||
const label = props.label || 'Comment';
|
const label = props.label || 'Comment';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user