mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
f2553d39da
Summary: The `ReactNativeVersion.h` file currently contains a `struct` that holds the React Native version (e.g. `1000.0.0`, as individual ints). For some libraries, we need to conditionally compile out code when using an older React Native version, and that's where library authors usually set compiler flags that hold the react native version - those are usually resolved using a `node require.resolve` script in the Podspec or build.gradle, adding unnecessary complexity. With this PR this becomes obsolete as we now create a `#define` that holds the React Native version directly - so e.g. ```cpp #define REACT_NATIVE_VERSION_MAJOR 0 #define REACT_NATIVE_VERSION_MINOR 67 #define REACT_NATIVE_VERSION_PATCH 1 ``` ..which we can then use to conditionally compile some code in our libraries: ```cpp #include <React/ReactNativeVersion.h> #if REACT_NATIVE_VERSION_MINOR >= 76 // new stuff #else // fallback #endif ``` ## Changelog: [INTERNAL] [ADDED] - Added `REACT_NATIVE_VERSION_*` C++ defines to `ReactNativeVersion.h` <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests Pull Request resolved: https://github.com/facebook/react-native/pull/48813 Test Plan: Just import the header in a library and check if the defines exist! Reviewed By: cortinico Differential Revision: D68441049 Pulled By: javache fbshipit-source-id: 55ac8875e1a3f8ad8b9d12795fed4204e9c5bb77