pixi-react icon indicating copy to clipboard operation
pixi-react copied to clipboard

Incorrect TypeScript Type for `oldProps` in CustomComponent#applyProps

Open mutewinter opened this issue 3 years ago • 2 comments

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

  1. Create a custom component
  2. Define applyProps
  3. See invalid type for oldProps

Additional info

  • @inlet/react-pixi version: 6.8.0
  • React version: 17
  • ReactDOM version: 17
  • PIXI version: 6

mutewinter avatar Jun 25 '22 17:06 mutewinter

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?

inlet avatar Jun 28 '22 10:06 inlet

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.

mutewinter avatar Jul 03 '22 22:07 mutewinter