Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make psychsheets sort by average by default #10368

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, {
useMemo,
useReducer,
useState,
useEffect
} from 'react';
import {
Flag, Icon, Segment, Table,
Expand Down Expand Up @@ -95,7 +96,15 @@ export default function RegistrationList({ competitionInfo }) {
const changeSortColumn = (name) => dispatch({ type: 'CHANGE_SORT', sortColumn: name });

const [psychSheetEvent, setPsychSheetEvent] = useState();
const [psychSheetSortBy, setPsychSheetSortBy] = useState('single');
const [psychSheetSortBy, setPsychSheetSortBy] = useState('average');

useEffect(() => {
if (psychSheetEvent === '333mbf') {
setPsychSheetSortBy('single');
} else {
setPsychSheetSortBy('average');
}
}, [psychSheetEvent]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a good usage of useEffect. In essence, you're only recomputing the initial value for useMemo above. So, you should replace this whole effect hook with a single line along the lines of const default sort = isMultiBld ? 'single' : 'average' and then pass that new value as initializer: useMemo(psychSheetEvent)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!


const { isLoading: isLoadingPsychSheet, data: psychSheet } = useQuery({
queryKey: [
Expand Down
Loading