Skip to content

Conversation

dmytrorykun
Copy link
Contributor

@dmytrorykun dmytrorykun commented Jul 15, 2024

Summary

This PR fixes the fastAddProperties function. Now it nullifies a prop if it was defined in one of the items of a style array, but then set to undefined or null in one of the subsequent items. E.g. style: [{top: 0}, {top: undefined}] should evaluate to {top: null}. Also added a test case for that.

How did you test this change?

yarn test packages/react-native-renderer -r=xplat --variant=false
yarn test packages/react-native-renderer -r=xplat --variant=true
yarn flow native

Copy link

vercel bot commented Jul 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 15, 2024 4:19pm

Comment on lines +63 to +70
it('should nullify previously defined style prop that is subsequently set to null or undefined', () => {
expect(
create({style: [{a: 0}, {a: undefined}]}, {style: {a: true}}),
).toEqual({a: null});
expect(create({style: [{a: 0}, {a: null}]}, {style: {a: true}})).toEqual({
a: null,
});
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is fastAddProperties tested in this codepath? Can we run these tests with enableAddPropertiesFastPath enabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, with

yarn test packages/react-native-renderer -r=xplat --variant=true

@dmytrorykun dmytrorykun merged commit f510ece into facebook:main Jul 15, 2024
github-actions bot pushed a commit that referenced this pull request Jul 15, 2024
## Summary

This PR fixes the `fastAddProperties` function. Now it nullifies a prop
if it was defined in one of the items of a style array, but then set to
`undefined` or `null` in one of the subsequent items. E.g. `style:
[{top: 0}, {top: undefined}]` should evaluate to `{top: null}`. Also
added a test case for that.

## How did you test this change?
```
yarn test packages/react-native-renderer -r=xplat --variant=false
yarn test packages/react-native-renderer -r=xplat --variant=true
yarn flow native
```

DiffTrain build for commit f510ece.
felixshiftellecon added a commit to felixshiftellecon/react that referenced this pull request Jul 24, 2024
## Summary

This PR fixes the `fastAddProperties` function. Now it nullifies a prop
if it was defined in one of the items of a style array, but then set to
`undefined` or `null` in one of the subsequent items. E.g. `style:
[{top: 0}, {top: undefined}]` should evaluate to `{top: null}`. Also
added a test case for that.

## How did you test this change?
```
yarn test packages/react-native-renderer -r=xplat --variant=false
yarn test packages/react-native-renderer -r=xplat --variant=true
yarn flow native
```
felixshiftellecon added a commit to felixshiftellecon/react that referenced this pull request Jul 24, 2024
## Summary

This PR fixes the `fastAddProperties` function. Now it nullifies a prop
if it was defined in one of the items of a style array, but then set to
`undefined` or `null` in one of the subsequent items. E.g. `style:
[{top: 0}, {top: undefined}]` should evaluate to `{top: null}`. Also
added a test case for that.

## How did you test this change?
```
yarn test packages/react-native-renderer -r=xplat --variant=false
yarn test packages/react-native-renderer -r=xplat --variant=true
yarn flow native
```
@dmytrorykun dmytrorykun deleted the fix-fastAddProps branch February 12, 2025 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants