enactjs / enact

An app development framework built atop React that’s easy to use, performant and customizable.
http://enactjs.com
Apache License 2.0
316 stars 31 forks source link

WRQ-31515: Fixed `Scroller`, `VirtualList`, and `VirtualGridList` to set prop value to default when `undefined` is passed for the prop value #3265

Closed juwonjeong closed 2 months ago

juwonjeong commented 3 months ago

Checklist

Issue Resolved / Feature Added

In https://github.com/enactjs/enact/pull/3238, we removed defaultProps and implemented this feature manually. After this implementation, if undefined is passed for a prop value, the prop value remains undefined. However, defaultProps(https://legacy.reactjs.org/docs/typechecking-with-proptypes.html#default-prop-values) sets prop value to default value when undefined value is passed for the prop.

Resolution

Fix Scroller, VirtualList and VirtualGridList to set prop value to default value when undefined is passed for the prop value

Additional Considerations

I checked React's defaultProps for falsy values(null, undefined, false, NaN, 0, -0, "") and found that it sets the prop value to its default value only when undefined is passed.

And it seems that React's defaultProps only checked undefined.

Links

WRQ-31515

Comments

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 82.52%. Comparing base (ef8be8e) to head (cdbdc77). Report is 2 commits behind head on release/4.9.x.develop.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## release/4.9.x.develop #3265 +/- ## ========================================================= + Coverage 82.51% 82.52% +0.01% ========================================================= Files 157 157 Lines 7245 7251 +6 Branches 1919 1921 +2 ========================================================= + Hits 5978 5984 +6 Misses 995 995 Partials 272 272 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.