Skip to content

Commit

Permalink
Clearing error state when value selected
Browse files Browse the repository at this point in the history
  • Loading branch information
carloslimasd committed Jun 26, 2024
1 parent c2012ae commit e2f8f87
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from 'react'
import React, { useState } from 'react'
import { Dropdown } from '../../'

const DropdownError = (props) => {
const [selectedOption, setSelectedOption] = useState()
const error = selectedOption?.value ? null : "Please make a valid selection"
const options = [
{
label: "United States",
Expand All @@ -15,12 +17,13 @@ const DropdownError = (props) => {
label: "Pakistan",
value: "Pakistan",
}
];
]

return (
<>
<Dropdown
error="Please make a valid selection"
error={error}
onSelect={(selectedItem) => setSelectedOption(selectedItem)}
options={options}
{...props}
/>
Expand Down

0 comments on commit e2f8f87

Please sign in to comment.