Carefully evaluate whether functionality needs to be exposed as public API. Keep implementations private when they're only used internally, and avoid creating public APIs that increase maintenance burden without clear benefit.
Carefully evaluate whether functionality needs to be exposed as public API. Keep implementations private when they’re only used internally, and avoid creating public APIs that increase maintenance burden without clear benefit.
Before exposing new public APIs, consider:
Example from the codebase:
// Instead of exposing this in the header as public API:
RCT_EXTERN UIDeviceOrientation RCTDeviceOrientation(void);
// Keep it private in the .mm file since it's only used internally:
static UIDeviceOrientation RCTDeviceOrientation(void) {
// implementation
}
For experimental features, use feature flags rather than exposing unstable APIs:
// Experimental APIs should be clearly marked and gated
textInputEventEmitter.experimental_flushSync([state = _state, data = std::move(data)]() mutable {
// experimental functionality
});
This approach reduces maintenance overhead, prevents API bloat, and gives teams flexibility to refactor internal implementations without breaking public contracts.
Enter the URL of a public GitHub repository