Skip to content

Commit

Permalink
add useEffect when props.visiable changing
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitalik7 authored and xcarpentier committed Nov 20, 2019
1 parent 923c2a6 commit 0258a31
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/CountryPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ export const CountryPicker = (props: CountryPickerProps) => {
})
const { translation, getCountriesAsync } = useContext()
const { visible, filter, countries, filterFocus } = state

useEffect(() => {
if (state.visible !== props.visible) {
setState({ ...state, visible: props.visible });
}
}, [props.visible])

const onOpen = () => {
setState({ ...state, visible: true })
if (handleOpen) {
Expand Down

0 comments on commit 0258a31

Please sign in to comment.