Skip to content
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

Stop using defaultProps for LazyLoadedImage #3957

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 1 addition & 24 deletions src/components/IIIFThumbnail.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
Component, useMemo, useEffect, useState,
} from 'react';
import PropTypes from 'prop-types';
import { styled } from '@mui/material/styles';
import { useInView } from 'react-intersection-observer';
import getThumbnail from '../lib/ThumbnailFactory';
Expand All @@ -22,7 +21,7 @@
* try to load the image (or even calculate that the image url/height/width are)
*/
const LazyLoadedImage = ({
border, placeholder, style = {}, thumbnail, resource, maxHeight, maxWidth, thumbnailsConfig, ...props
placeholder, style = {}, thumbnail, resource, maxHeight, maxWidth, thumbnailsConfig = {}, border = false, ...props

Check failure on line 24 in src/components/IIIFThumbnail.js

View workflow job for this annotation

GitHub Actions / build (18.x)

'placeholder' is missing in props validation

Check failure on line 24 in src/components/IIIFThumbnail.js

View workflow job for this annotation

GitHub Actions / build (18.x)

'style' is missing in props validation

Check failure on line 24 in src/components/IIIFThumbnail.js

View workflow job for this annotation

GitHub Actions / build (18.x)

'thumbnail' is missing in props validation

Check failure on line 24 in src/components/IIIFThumbnail.js

View workflow job for this annotation

GitHub Actions / build (18.x)

'resource' is missing in props validation

Check failure on line 24 in src/components/IIIFThumbnail.js

View workflow job for this annotation

GitHub Actions / build (18.x)

'maxHeight' is missing in props validation

Check failure on line 24 in src/components/IIIFThumbnail.js

View workflow job for this annotation

GitHub Actions / build (18.x)

'maxWidth' is missing in props validation

Check failure on line 24 in src/components/IIIFThumbnail.js

View workflow job for this annotation

GitHub Actions / build (18.x)

'thumbnailsConfig' is missing in props validation

Check failure on line 24 in src/components/IIIFThumbnail.js

View workflow job for this annotation

GitHub Actions / build (18.x)

'border' is missing in props validation

Check failure on line 24 in src/components/IIIFThumbnail.js

View workflow job for this annotation

GitHub Actions / build (20.x)

'placeholder' is missing in props validation

Check failure on line 24 in src/components/IIIFThumbnail.js

View workflow job for this annotation

GitHub Actions / build (20.x)

'style' is missing in props validation

Check failure on line 24 in src/components/IIIFThumbnail.js

View workflow job for this annotation

GitHub Actions / build (20.x)

'thumbnail' is missing in props validation

Check failure on line 24 in src/components/IIIFThumbnail.js

View workflow job for this annotation

GitHub Actions / build (20.x)

'resource' is missing in props validation

Check failure on line 24 in src/components/IIIFThumbnail.js

View workflow job for this annotation

GitHub Actions / build (20.x)

'maxHeight' is missing in props validation

Check failure on line 24 in src/components/IIIFThumbnail.js

View workflow job for this annotation

GitHub Actions / build (20.x)

'maxWidth' is missing in props validation

Check failure on line 24 in src/components/IIIFThumbnail.js

View workflow job for this annotation

GitHub Actions / build (20.x)

'thumbnailsConfig' is missing in props validation

Check failure on line 24 in src/components/IIIFThumbnail.js

View workflow job for this annotation

GitHub Actions / build (20.x)

'border' is missing in props validation
}) => {
const { ref, inView } = useInView();
const [loaded, setLoaded] = useState(false);
Expand Down Expand Up @@ -114,28 +113,6 @@
);
};

LazyLoadedImage.propTypes = {
border: PropTypes.bool,
maxHeight: PropTypes.number.isRequired,
maxWidth: PropTypes.number.isRequired,
placeholder: PropTypes.string.isRequired,
resource: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
style: PropTypes.object, // eslint-disable-line react/forbid-prop-types
thumbnail: PropTypes.shape({
height: PropTypes.number,
url: PropTypes.string.isRequired,
width: PropTypes.number,
}),
thumbnailsConfig: PropTypes.object, // eslint-disable-line react/forbid-prop-types
};

LazyLoadedImage.defaultProps = {
border: false,
style: {},
thumbnail: null,
thumbnailsConfig: {},
};

/**
* Uses InteractionObserver to "lazy" load canvas thumbnails that are in view.
*/
Expand Down Expand Up @@ -197,8 +174,8 @@
}

IIIFThumbnail.propTypes = {
border: PropTypes.bool,

Check failure on line 177 in src/components/IIIFThumbnail.js

View workflow job for this annotation

GitHub Actions / build (18.x)

'PropTypes' is not defined

Check failure on line 177 in src/components/IIIFThumbnail.js

View workflow job for this annotation

GitHub Actions / build (20.x)

'PropTypes' is not defined
children: PropTypes.node,

Check failure on line 178 in src/components/IIIFThumbnail.js

View workflow job for this annotation

GitHub Actions / build (18.x)

'PropTypes' is not defined

Check failure on line 178 in src/components/IIIFThumbnail.js

View workflow job for this annotation

GitHub Actions / build (20.x)

'PropTypes' is not defined
imagePlaceholder: PropTypes.string,
label: PropTypes.string,
labelled: PropTypes.bool,
Expand Down
Loading