Skip to content

Remove const_cast from appendChild by fixing API signature#55784

Open
sammy-SC wants to merge 2 commits intofacebook:mainfrom
sammy-SC:export-D90763774
Open

Remove const_cast from appendChild by fixing API signature#55784
sammy-SC wants to merge 2 commits intofacebook:mainfrom
sammy-SC:export-D90763774

Conversation

@sammy-SC
Copy link
Contributor

Summary:
Change appendChild to take non-const parent ShadowNode pointer since the
method mutates the parent by appending a child to it. This removes the
const_cast in ConcreteComponentDescriptor::appendChild which was a code
smell.

The parent node is always unsealed during tree construction when
appendChild is called, so passing a non-const pointer accurately
reflects the mutation that occurs.

Changelog:
[Internal] [Changed] - Remove const_cast from appendChild in Fabric renderer

Reviewed By: javache

Differential Revision: D90763774

Summary:

Changelog: [Internal]

remove unnecessary const from ShadowNodeFamily. This allows us to get rid of a few mutable keywords.

Reviewed By: christophpurrer

Differential Revision: D90763777
Summary:
Change appendChild to take non-const parent ShadowNode pointer since the
method mutates the parent by appending a child to it. This removes the
const_cast in ConcreteComponentDescriptor::appendChild which was a code
smell.

The parent node is always unsealed during tree construction when
appendChild is called, so passing a non-const pointer accurately
reflects the mutation that occurs.

Changelog:
[Internal] [Changed] - Remove const_cast from appendChild in Fabric renderer

Reviewed By: javache

Differential Revision: D90763774
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 26, 2026
@meta-codesync
Copy link

meta-codesync bot commented Feb 26, 2026

@sammy-SC has exported this pull request. If you are a Meta employee, you can view the originating Diff in D90763774.

sammy-SC added a commit to sammy-SC/react-native that referenced this pull request Feb 27, 2026
…55784)

Summary:

Change appendChild to take non-const parent ShadowNode pointer since the
method mutates the parent by appending a child to it. This removes the
const_cast in ConcreteComponentDescriptor::appendChild which was a code
smell.

The parent node is always unsealed during tree construction when
appendChild is called, so passing a non-const pointer accurately
reflects the mutation that occurs.

Changelog:
[Internal] [Changed] - Remove const_cast from appendChild in Fabric renderer

Reviewed By: javache

Differential Revision: D90763774
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants