pixi-react
pixi-react copied to clipboard
Incorrect TypeScript Type for `oldProps` in CustomComponent#applyProps
Description
oldProps is defined here as oldProps: Readonly<P>,, however on first render it is an empty object. This can cause errors when attempting to access oldProps values on first render.
Steps to reproduce
- Create a custom component
- Define
applyProps - See invalid type for
oldProps
Additional info
@inlet/react-pixiversion: 6.8.0Reactversion: 17ReactDOMversion: 17PIXIversion: 6
This is correctly, on initial render it doesn't have any old props on it.. we might set the type to something like Readonly<P> | undefined?
Currently it’s an empty object, which means it doesn’t throw when accessing one level deep props. But I agree with changing it to undefined is more clear. It would be a breaking change.