-
Notifications
You must be signed in to change notification settings - Fork 64
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
<Background> generating parameters twice for width and height #763
Comments
Hey @JorgeSivil, thanks for bringing this issue to our attention. Our team will look into this and get back to you here. We'd also be happy to accept a PR that fixes this issue if anyone is interested in opening one. |
Reproduced. Steps to reproduce:
import { Background } from "react-imgix";
function App() {
return (
<Background
src="https://assets.imgix.net/dam-marketing/Updates_2020_Launch/Summer/Image_Tags.png?fm=jpg&q=90&ixlib=imgixjs-3.4.1"
className="blog-title"
imgixParams={{ w: 100, h: 100 }}
>
<h2>Blog Title</h2>
</Background>
);
}
export default App; Options:
Test to catch this error: describe("when both w and h provided", () => {
it("does not duplicate query params for height and width", () => {
const sut = renderIntoContainer(
<Background
src="https://assets.imgix.net/examples/pione.jpg"
imgixParams={{
w: 300,
h: 350,
}}
className="bg-img"
></Background>
);
const bgImageSrcURL = findURIfromSUT(sut);
const seen = new Set();
for (const [k, _v] of bgImageSrcURL.queryPairs) {
if (seen.has(k)) {
throw new Error(
`duplicate keys for '${k}' found in query parameters`
);
} else {
seen.add(k);
}
}
});
}); |
We could also deduplicate any |
Yeah, ideally I'd like to set things up in a way where the duplication doesn't happen to begin with. Hmm... |
* build: add @imgix/js-core as a dependency * feat: impl targetWidths in terms of ImgixClient.targetWidths() * feat: impl buildSrcSet in terms of @imgix/js-core * fix: test that issue #763 has been fixed * refactor: remove dead code * refactor: tidy up * fix: no need to include w or h if building fluid-width srcset
🎉 This issue has been resolved in version 9.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
* fix(BackgroundImpl): re-render only if a larger image is needed * refactor: component should update if props or imgixParams change * chore(release): 9.1.0 ## [9.1.0](v9.0.4...v9.1.0) (2021-04-22) ### Features * integrate @imgix/js-core into react-imgix ([#780](#780)) ([690e7b6](690e7b6)), closes [#763](#763) [skip ci] Co-authored-by: imgix-git-robot <[email protected]>
Based on the code I had to send imgixParams{ w: X, h: Y } to use the forced values.
But this would result in two parameters w and h appended to the URL.
Expected result: Only one parameter should be sent for a given key.
The text was updated successfully, but these errors were encountered: