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

Invalid props passed to View element in Card.tsx

Open juhasuni opened this issue 3 years ago • 4 comments

Current behavior

A View component used in Card.tsx receives all props from object rest. However, this object contains lots of props that are not recognized by the View. This may cause bugs in the future when a new prop gets unintentionally passed onto View.

Expected behavior

View should receive only props that are supported.

Reproduction

https://github.com/react-navigation/react-navigation/blob/b28bb2b45ee39a8062020fba667e155c342c6629/packages/stack/src/views/Stack/Card.tsx#L520

Platform

  • [X] Android
  • [X] iOS
  • [X] Web
  • [X] Windows
  • [X] MacOS

Packages

  • [ ] @react-navigation/​bottom-tabs
  • [ ] @react-navigation/​drawer
  • [ ] @react-navigation/​material-bottom-tabs
  • [ ] @react-navigation/​material-top-tabs
  • [X] @react-navigation/​stack
  • [ ] @react-navigation/​native-stack

Environment

  • [x] I've removed the packages that I don't use
package version
@react-navigation/stack 6.2.2
@react-navigation/native 6.0.11
react-native 0.68.2
node 16.16.0
npm or yarn 1.22.19 (yarn)

juhasuni avatar Aug 31 '22 11:08 juhasuni

Hey! Thanks for opening the issue. The issue doesn't seem to contain a link to a repro (a snack.expo.dev link, a www.typescriptlang.org/play link or link to a GitHub repo under your username).

Can you provide a minimal repro which demonstrates the issue? Please try to keep the repro as small as possible and make sure that we can run it without additional setup.

A repro will help us debug the issue. The issue will be closed automatically after a while if you don't provide a repro.

github-actions[bot] avatar Aug 31 '22 11:08 github-actions[bot]

Couldn't find version numbers for the following packages in the issue:

  • @react-navigation/native

Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3.

The versions mentioned in the issue for the following packages differ from the latest versions on npm:

  • @react-navigation/stack (found: 6.2.2, latest: 6.2.3)

Can you verify that the issue still exists after upgrading to the latest versions of these packages?

github-actions[bot] avatar Aug 31 '22 11:08 github-actions[bot]

The versions mentioned in the issue for the following packages differ from the latest versions on npm:

  • @react-navigation/stack (found: 6.2.2, latest: 6.2.3)
  • @react-navigation/native (found: 6.0.11, latest: 6.0.12)

Can you verify that the issue still exists after upgrading to the latest versions of these packages?

github-actions[bot] avatar Aug 31 '22 11:08 github-actions[bot]

Using {...rest} pattern for providing props to View works fine with functional components, where it is easier to see how other props are being consumed. With class based components this is much more difficult, and I'd avoid using this pattern with class components.

For instance with Card.tsx there are internal methods that rely on certain props but then the render method doesn't care about those props at all. It is difficult to see in render method which props are used and for what.

juhasuni avatar Aug 31 '22 11:08 juhasuni

Hello 👋, this issue has been open for more than a month without a repro or any activity. If the issue is still present in the latest version, please provide a repro or leave a comment within 7 days to keep it open, otherwise it will be closed automatically. If you found a solution or workaround for the issue, please comment here for others to find. If this issue is critical for you, please consider sending a pull request to fix it.

github-actions[bot] avatar Oct 01 '22 02:10 github-actions[bot]