-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 src props for urls #1142
Comments
What is |
|
There's no CSS property named What's wrong with this code alone?
Why do you need the |
Why does my component still work if there is no
But for each instance of the component I want the image source to be different:
I'd gladly use the built-in |
Ok. I just got the same error using |
if anyone is having this issue the problem I was facing is solved here: facebook/react#6472 |
@pak11273 isn't this just because you are adding a
This allows you to add the prop |
@Caryyon I haven't tested that out yet, but I want the src prop to be dynamic. So I could do this:
|
@pak11273 the line you just wrote would work fine for that. Are you then asking how would you use the when you make the
the above code would render two different images as you've given them 2 different urls. |
No I am not having this issue anymore. I forgot how I fixed the issue but I resolved it over here. The error was from react and not styled-components. |
Kind of related to this - how can I conditionally set an image src on break point? I've tried this but its not right
|
@LouiseReid You might try |
@LouiseReid that's where you might have to write a higher order component to wrap this one and adjust its props according to the width of the window. At this point though i think you are better off making a
|
Thanks @Caryyon, thats what I ended up doing. It just felt a bit icky as I'd lose alt tags etc |
This is not so right. the idea is: To have img tag and src attribute changing depending on device width. |
const MyImg = styled.div |
Version
2.1.0
I have an option to use any url for the source to my image component and it works. However, in the console I keep getting a Type error in the console:
Uncaught TypeError: Cannot read property '__reactInternalInstance$h4ttge1zri8' of null
Steps to reproduce
Is there another way to do this?
The text was updated successfully, but these errors were encountered: