-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image primitive doesn't exact same behaviour as react native #105
Comments
are you talking about web vs react-native? |
@mathieudutour eaxctly, in the code in my storybook the In my styles I only specified the width, on react-native it resizes in proportion to the height but on react-web it ends up wrapped in a div and used as background image so it ends up being the width but obviously won't adjust the height as thats not how background images work. Right now I've specified an explicit height as a work around but it was a surprise :) |
There are other behaviors that this causes issues with, like being able to make an image be contained within a div as is surrounding parent gets smaller. Happy to make a PR for this as I think just having it use the |
This issue is probably best for React Native has quite specific requirements in terms of having image width/height knowledge, which may or may not be applicable to web. ( I am doing this myself (component lib This should be possible with the injection API in your app initialisation:
import ReactPrimitives from 'react-primitives';
// TODO: Implement `aspectRatio` styling prop with `source.width` and `source.height`
const Image = ({ source, style, ...props }) => (
<img style={style} src={source.uri} {...props} />
);
ReactPrimitives.inject({
Image,
});
const App = () => (
<DataProvider>
{...} |
Since the implementation of this seems to be a div with a background image, some layout functionality behaves differently due to the CSS spec.
If this was implemented instead as a actual
img
tag, the behave should match more closely the layout behaviour experienced by images on React Native.The text was updated successfully, but these errors were encountered: