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

fix: undefined and null wrap prop values are rendered as undefined instead of true by default

Open EvHaus opened this issue 8 months ago • 3 comments

Similar to #3149 and #3142, this PR fixes a bug introduced in this change. When a wrap value of undefined or null is passed to <View> components, the latest versions of react-pdf will treat it as false instead of true (which should be the default value).

Also adds tests for this function.

EvHaus avatar Apr 19 '25 03:04 EvHaus

⚠️ No Changeset found

Latest commit: 7324cf248d414c4d4781947352db63044ea8f1c2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Apr 19 '25 03:04 changeset-bot[bot]

Is it correct that undefined was already returning true? I'm not sure about null though. That's a falsy value. Makes more sense to me to false for null than true

diegomura avatar Sep 23 '25 20:09 diegomura

Is it correct that undefined was already returning true?

The current behaviour is:

  1. <View /> is treated as true
  2. <View wrap={undefined} /> is treated as false
  3. <View wrap={null} /> is treated as false
  4. <View wrap={false} /> is treated as false
  5. <View wrap={true} /> is treated as false

I think 1, 4 and 5 make sense. But 2 and 3 are unexpected to me.

I'm not sure about null though. That's a falsy value. Makes more sense to me to false for null than true

I see where you're coming from however given that "no value" (case 1) and undefined (case 2) will evaluate to true I think having null evaluate to true is a more developer-friendly/consistent experience.

Let me know if you feel strongly about it and I'll make the PR change accordingly. Thanks @diegomura!

EvHaus avatar Sep 30 '25 23:09 EvHaus