aphrodite
aphrodite copied to clipboard
Add public API to determine if an object is an aphrodite style or not
I'm working on some components that have a style
prop that's similar to the style
prop in React Native components which can take either inline styles or styles from StyleSheet objects. The components need to know how to disambiguate between the types of objects being passed in so that they can apply the slides correctly in the render method.
Proposed API:
function isAphroditeStyle(style: any) => boolean
We do this in react-with-styles-interface-aphrodite. https://github.com/airbnb/react-with-styles-interface-aphrodite/blob/e9c088d8998bed347ff5c26f54a22d8dfd633cb6/src/utils/separateStyles.js
Can you make a case for adding it to this project vs a separate project or something?
If we change the internal implementation of Aphrodite it will break that code. It seems like a generally useful function to have to support tooling. We could do it in a separate package but that package should be part of this repo and have tests so in order to avoid breakages.
Sure, might as well I guess. Want to submit a PR? It would be great if your PR refactored any internal code that might benefit to also use this function.
If I understand tree-shaking correctly, we should be able to expose this as a named export and it won't affect consumer bundle sizes if they don't import it.
If the function is use internally people will still get the code.