Skip to content

Commit 0258a31

Browse files
Vitalik7xcarpentier
authored andcommitted
add useEffect when props.visiable changing
1 parent 923c2a6 commit 0258a31

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/CountryPicker.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ export const CountryPicker = (props: CountryPickerProps) => {
115115
})
116116
const { translation, getCountriesAsync } = useContext()
117117
const { visible, filter, countries, filterFocus } = state
118+
119+
useEffect(() => {
120+
if (state.visible !== props.visible) {
121+
setState({ ...state, visible: props.visible });
122+
}
123+
}, [props.visible])
124+
118125
const onOpen = () => {
119126
setState({ ...state, visible: true })
120127
if (handleOpen) {

0 commit comments

Comments
 (0)