Skip to content

Commit

Permalink
remove state depedency
Browse files Browse the repository at this point in the history
  • Loading branch information
nileshgulia1 committed Oct 14, 2020
1 parent 77a309d commit 70dad65
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/components/manage/Widgets/GeolocationWidget.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const Group = (props) => <components.Group {...props} />;

const GeolocationWidget = (props) => {
const { data, block, onChange, intl, id } = props;
const [geoGroup, setGeoGroup] = useState(null);

let options = [
{
Expand All @@ -49,12 +48,7 @@ const GeolocationWidget = (props) => {
const handleChange = (e, value) => {
let arr = [];
arr = eeaCountries.filter((item) => item.group?.includes(e.label));
setGeoGroup((prevState) => {
return {
label: 'Countries group',
options: getOptions(arr, prevState),
};
});
onChange(getOptions(data.geolocation, arr));
};

return (
Expand Down Expand Up @@ -103,11 +97,8 @@ const GeolocationWidget = (props) => {
styles={customSelectStyles}
theme={selectTheme}
components={{ DropdownIndicator, Option, Group }}
value={
geoGroup ? geoGroup.options || [...geoGroup] : data.geolocation
}
value={data.geolocation}
onChange={(field, value) => {
setGeoGroup(() => field);
onChange(field, value === '' ? undefined : value);
}}
/>
Expand Down

0 comments on commit 70dad65

Please sign in to comment.