-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
src/hooks/useHassuTable.tsx
Outdated
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; | ||
}; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 👍
There was a problem hiding this comment.
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
…ta luetaan nyt projektin tiedoista.
…margin-hommat meni huonosti.
…saa koko ajan uudet propsit, eli renderöityy turhaan uudestaan, jos checkboxia klikataan.
…uvaiheen vuorovaikutuksessa
769bc8f
to
ebfef01
Compare
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.