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

feat: hassu 898 nopeutukset #318

Merged
merged 6 commits into from
Aug 17, 2022
Merged

Conversation

ValheKouneli
Copy link
Contributor

Korjaus siihen, miten kunnan nimi haetaan suunnitteluvaiheen vuorovaikutuksessa. Nyt kunnan s.postin kirjoittaminen ei jumita.
Purkkakorjaus useHassuTableen, jotta se ei rendaa uudestaan ja uudestaan.
Refaktorointi vuorovaikutuslomakkeen Suunnitelmat ja Aineistot -osiolle.

Comment on lines 14 to 38
import { Column, TableState } from "react-table";

interface Test<D extends object> {
columns: readonly Column<D>[];
data: readonly D[];
initialState: Partial<TableState<D>> | undefined;
}

export const useHassuTableStabilizer = <D extends object>(tableOptions: Test<D>): HassuTableProps<D> => {
const [tableProps, setTableProps] = useState<HassuTableProps<D> | null>(null);

const newTableProps = useHassuTable<D>({
tableOptions,
useRowSelect: true,
});

useEffect(() => {
if (!tableProps) {
setTableProps(newTableProps);
}
}, [tableProps, setTableProps, newTableProps]);

if (!tableProps) return newTableProps;
return tableProps;
};
Copy link
Contributor

@tkork tkork Aug 16, 2022

Choose a reason for hiding this comment

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

Tonne on tainnut jäädä testailulta tyypille nimeks Test.

Toiseks tää stabilizer nyt raa'asti vaan estää tablePropsien päivityksen (ja HassuTablen rendauksen) vaikka tälle hookille annetut propsit muuttusikin. Mun käsityksen mukaa useHassuTable -hookkiin jos lisäis memoizausta muutamaan kohtaan niin sais vähennettyä renderaus kertoja kuitenkaan estämättä sen uudelleen renderausta. Testailin lisäämällä memoizointia tableHooks, defaultTableOptions, tableProps ja returnattavaan arvoon. Näin sain ne moneen kertaan renderoinnit estettyä.

Kannattaisiko tää ennemmin tehdä sillä tavalla?

Copy link
Contributor

@tkork tkork Aug 16, 2022

Choose a reason for hiding this comment

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

Muuten tää PR on mun mielestä OK 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Keskusteltiin, että teen oman PR:n näistä useHassuTable-muutoksista ja riisutaan ne tästä PR:stä kokonaan pois

@ValheKouneli ValheKouneli merged commit be8348b into main Aug 17, 2022
@ValheKouneli ValheKouneli deleted the feature/HASSU-898-nopeutukset branch August 17, 2022 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants