Skip to content

Commit 14f7ea0

Browse files
committed
RruTextareaInput now support setting the value from the context
1 parent cf95894 commit 14f7ea0

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/form/RruDateTimeInput/types/RruDateTimeInputProps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default interface RruDateTimeInputProps {
2828
/** */
2929
requiredAsterisk?: boolean;
3030

31-
/** The minium selectable year */
31+
/** */
3232
mode?: RruDateTimeInputMode;
3333

3434
/** */

src/form/RruTextareaInput/RruTextareaInput.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,18 @@
1616

1717
import React, { FC, useEffect, useState } from 'react';
1818
import ErrorMessage from '../ErrorMessage/ErrorMessage';
19-
import { useField } from '../hooks/useField';
2019
import Label from '../Label/Label';
20+
import { useField } from '../hooks/useField';
2121
import RruTextareaInputProps from './types/RruTextareaInputProps';
2222

2323
const RruTextareaInput: FC<RruTextareaInputProps> = (props) => {
2424
const [value, setValue] = useState<string | null>(null);
25-
const field = useField(props.name);
25+
26+
const field = useField(props.name, (serializedValue) => {
27+
if (serializedValue !== value) {
28+
setValue(serializedValue);
29+
}
30+
});
2631

2732
const setNewValue = (val: string | null) => {
2833
field.setValue(val);

0 commit comments

Comments
 (0)