Skip to content

Commit

Permalink
adding ErrorExample to TextInputSharedExamples
Browse files Browse the repository at this point in the history
  • Loading branch information
fabOnReact committed Mar 12, 2022
1 parent fb30702 commit f22e1f3
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,28 @@ class SelectionExample extends React.Component<
}
}

function ErrorExample(): React.Node {
const [text, setText] = React.useState('');
const [error, setError] = React.useState(null);
return (
<TextInput
errorMessage={error}
onChangeText={newText => {
setText(newText);
setError(newText === 'error' ? 'this input is invalid' : null);
}}
value={text}
/>
);
}

module.exports = ([
{
title: 'Error Message',
render: function (): React.Node {
return <ErrorExample />;
},
},
{
title: 'Auto-focus',
render: function (): React.Node {
Expand Down

0 comments on commit f22e1f3

Please sign in to comment.