mirror of
https://github.com/react/react-native.git
synced 2026-09-28 05:13:06 +08:00
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/56478 Changelog: [General] [Fixed] - Respect enum values for TurboModule c++ codegen Defining an enum like this: ```js export enum CustomPropertyEditor { BitMask = 0, Entity = 1, Slider = 2, AudioEvent = 3, CollisionLayer = 4, MaterialComponentDeprecatedProperty = 5, MeshMaterialList = 6, Submesh = 7, // CoreUiLayout (8) removed — rendered identically to ClassOrList MaterialMapJson = 9, AnimationTable = 10, SkeletonAsset = 11, NavMeshAreaType = 12, VFXAsset = 13, Table = 14, VariableTable = 15, AudioBus = 16, LodSettings = 17, WorldSearch = 18, EntityMaterialList = 19, NpcId = 20, LightingModelVersion = 21, PlatformSelector = 22, ComponentReference = 23, } ``` (notice number 8 ), will cause the generated enum to actually look like: ``` enum class NativeEditableObjectModuleCustomPropertyEditor { BitMask, Entity, Slider, AudioEvent, CollisionLayer, MaterialComponentDeprecatedProperty, MeshMaterialList, Submesh, MaterialMapJson, AnimationTable, ... }; ``` in other words, the values don't match up after the core ui value. This is quite dangerous and I'm surprised no one has ever noticed that This diff fixes things such that if an integer value is explicitly assigned, the value is preserved in the generated enum. Reviewed By: christophpurrer Differential Revision: D101229471 fbshipit-source-id: 366ea2d16ac74e112f1b68c5ad3d0877dedb918c
@react-native/codegen
Installation
yarn add --dev @react-native/codegen
Note: We're using yarn to install deps. Feel free to change commands to use npm 3+ and npx if you like
Testing
To run the tests in this package, run the following commands from the React Native root folder:
yarnto install the dependencies. You just need to run this onceyarn jest packages/react-native-codegen.