Skip to content

Commit

Permalink
destructure the props
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotrfj committed Aug 21, 2023
1 parent 6024bce commit 22042e5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/pages/SearchPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ const defaultProps = {
reports: {},
};

function SearchPage(props) {
function SearchPage({betas, personalDetails, reports}) {
// Data for initialization (runs only on the first render)
const {
recentReports: initialRecentReports,
personalDetails: initialPersonalDetails,
userToInvite: initialUserToInvite,
// Ignoring the rule because in this case we need the data only initially
// eslint-disable-next-line react-hooks/exhaustive-deps
} = useMemo(() => OptionsListUtils.getSearchOptions(props.reports, props.personalDetails, '', props.betas), []);
} = useMemo(() => OptionsListUtils.getSearchOptions(reports, personalDetails, '', betas), []);

const [searchValue, setSearchValue] = useState('');
const [searchOptions, setSearchOptions] = useState({
Expand All @@ -62,14 +62,14 @@ function SearchPage(props) {
recentReports: localRecentReports,
personalDetails: localPersonalDetails,
userToInvite: localUserToInvite,
} = OptionsListUtils.getSearchOptions(props.reports, props.personalDetails, searchValue.trim(), props.betas);
} = OptionsListUtils.getSearchOptions(reports, personalDetails, searchValue.trim(), betas);

setSearchOptions({
recentReports: localRecentReports,
personalDetails: localPersonalDetails,
userToInvite: localUserToInvite,
});
}, [props.reports, props.personalDetails, searchValue, props.betas]);
}, [reports, personalDetails, searchValue, betas]);

const debouncedUpdateOptions = useMemo(() => _.debounce(updateOptions, 75), [updateOptions]);

Expand Down Expand Up @@ -146,7 +146,7 @@ function SearchPage(props) {
}
};

const isOptionsDataReady = ReportUtils.isReportDataReady() && OptionsListUtils.isPersonalDetailsReady(props.personalDetails);
const isOptionsDataReady = ReportUtils.isReportDataReady() && OptionsListUtils.isPersonalDetailsReady(personalDetails);
const headerMessage = OptionsListUtils.getHeaderMessage(
searchOptions.recentReports.length + searchOptions.personalDetails.length !== 0,
Boolean(searchOptions.userToInvite),
Expand Down

0 comments on commit 22042e5

Please sign in to comment.