Skip to content

Fix addKeyProp to not mutate props object #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 25, 2022
Merged

Conversation

cknitt
Copy link
Member

@cknitt cknitt commented Oct 25, 2022

I just noticed that the existing implementation of addKeyProp is mutating the props, just like the

(props->Obj.magic)["key"] = key

idea that we discussed previously.

This is because Object.assign mutates its first argument.
This PR fixes that.

@cknitt cknitt requested review from mununki and cristianoc October 25, 2022 09:42
@cknitt
Copy link
Member Author

cknitt commented Oct 25, 2022

BTW, why are we keeping the helper functions needed by the PPX in the main React module and not putting them in a separate module ReactPPXSupport or something like that?

@cknitt cknitt merged commit a3938ea into master Oct 25, 2022
@cknitt cknitt deleted the fix-add-key-props branch October 25, 2022 16:45
@mununki
Copy link
Member

mununki commented Oct 25, 2022

I didn't know this tip adding an empty object to avoid mutating. Thanks for this tip!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants