fix: warn the user when no <img> passed as a child to <picture> fixes #90 #151
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
BREAKING CHANGE: A fallback image will no longer be created when using react-imgix in picture mode
Description
The fallback image support when using react-imgix in
picture
mode was causing issues with sizing in #90 as the size being passed to the rootpicture
component was being used for the fallback as well. This was causing problems, and the simplest solution was to remove the fallback image creation. This is inline with the HTML spec, so anyone used to using<picture>
elements in HTML will be at home with this. There is more discussion in #90.A problem here is that
src
is a required prop for react-imgix, which will cause an error when usingpicture
mode as asrc
now isn't going to be passed to the root component. An option we have here is to update thesrc
prop to not be required, and just to warn the user when asrc
is not passed when the component is being used inimg
,bg
, orsource
. Another option is to wait to see if we implement the splitting of components as described in #144. In either way this needs to be discussed and resolved before this PR is merged.Also, since this is a breaking change, I'm going to merge this into the
version-8
branch, and I'll look to land all the breaking changes at once (e.g. the ones being discussed in #144).This PR fixes #90
Bug Fix
fix(<area>): fixed bug #issue-number
Steps to Test
Observe the changes to the unit tests in
test/unit/react-imgix.test.js