-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
feat(gatsby-image): Add customProps as catchall #25283
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -437,6 +437,7 @@ class Image extends React.Component { | |
itemProp, | ||
loading, | ||
draggable, | ||
tagProps = {}, | ||
} = convertProps(this.props) | ||
|
||
const shouldReveal = this.state.fadeIn === false || this.state.imgLoaded | ||
|
@@ -486,6 +487,7 @@ class Image extends React.Component { | |
}} | ||
ref={this.handleRef} | ||
key={`fluid-${JSON.stringify(image.srcSet)}`} | ||
{...tagProps} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be the first prop, place it above all others, otherwise it introduces the possibility to override all prior props for this component. |
||
> | ||
{/* Preserve the aspect ratio. */} | ||
<Tag | ||
|
@@ -601,6 +603,7 @@ class Image extends React.Component { | |
style={divStyle} | ||
ref={this.handleRef} | ||
key={`fixed-${JSON.stringify(image.srcSet)}`} | ||
{...tagProps} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as other comment, order matters, place this above all other props. |
||
> | ||
{/* Show a solid background color. */} | ||
{bgColor && ( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's be extra explicit here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not for the
img
element though? It's for thediv
(default tag) wrapper element. My review suggestedwrapperAttrs
orattrProps
which is more clear what the purpose of this props is(attributes for passing to the top-level element). We have lots of "image"/"tag"/"props" keywords in the file already, so I definitely think it's more clearer in all that keyword noise to be more specific it's about attributes.