Skip to content

Commit

Permalink
🐛 DateSelector - fix error message not displaying after errorMessage …
Browse files Browse the repository at this point in the history
…update
  • Loading branch information
Adrien Castagliola committed Feb 5, 2024
1 parent 8b3d91e commit c5a34b5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/dateSelector/DateSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { StyleSheet, TextInput, View } from 'react-native';
import { DateField } from './DateField';
import React, { useCallback, useRef, useState } from 'react';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { Theme, useTheme } from '../../styles/themes';
import { Headline } from '../typography/Headline';
import { Body } from '../typography/Body';
Expand Down Expand Up @@ -38,6 +38,10 @@ export const DateSelector = ({
const [yearField, setYearField] = useState('');
const [displayError, setDisplayError] = useState(!!errorMessage);

useEffect(() => {
setDisplayError(!!errorMessage);
}, [errorMessage]);

const refDay = useRef<TextInput>(null);
const refMonth = useRef<TextInput>(null);
const refYear = useRef<TextInput>(null);
Expand Down

0 comments on commit c5a34b5

Please sign in to comment.