I had performance issues with Visual Studio Code. I’ve tried everything and it finally ended up that these are project-connected issues. I’ve noticed that tsserver
is using a lot of RAM and CPU. I did some research and found out that the performance issues come from one of my utility functions for transient props.
export const $styled: CreateMUIStyled<Theme> = (
component: React.ComponentClass<React.ComponentProps<any>>
) =>
styled(component, {
shouldForwardProp: prop => typeof prop === 'string' && prop[0] !== '$',
})
Here is an example of one of the hot spots that tsc --generateTrace
and analyze-trace
gave me:
Check file /users/username/documents/workspace/projects/projectname/src/shared/components/typography/typography.tsx (21682ms)
It is pointing on $styled(Typography)
When I changed the declaration of $styled
to const $styled = styled
(so $styled now points to the regular MUI styled function) almost everything worked well.
How can I implement this utility function better or change the approach to avoid React errors about boolean props being passed to HTML?