react-native-optimizer

React Native, like many other libraries, has various checks/mappings either for legacy or developer experience purposes. This project is a micro-optimizer that statically analyses the code and will remap props/components to their more optimal versions.

This library is a prototype, ideas and contributes are very welcome.

Available Optimizations

Text -> NativeText

<Text /> is a wrapper around <NativeText /> that remaps props and creates a <TextAncestor /> context to inherit styles for nested <Text />. If you are not using any of the props which are remapped and your <Text /> children are strings, you can use <NativeText /> directly.

Contributions wanted

<Text /> optimizations

View -> ViewNativeComponent

<View /> is a wrapper around <ViewNativeComponent /> that remaps props and resets the <TextAncestor /> context. If you are not using any of the props which are remapped, and the <View /> is not nested within a <Text />, you can use <ViewNativeComponent /> directly.

Static style flattening

React Native components internally flatten styles at runtime, but often we can statically flatten styles at build time.

Credits

This project is inspired by