gatsby-core-theme 5.0.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## [5.0.1](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v5.0.0...v5.0.1) (2022-03-02)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * google bot images ([53fc90c](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/53fc90c24cc7bacc9d5911fb05c29dae611fbc1f))
7
+ * lazy image tests ([ef63ea8](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/ef63ea88cd2ff7b3dac335afd30e75e872cdff61))
8
+
9
+
10
+ * Merge branch 'tm-2743-googlebot-images' into 'master' ([2156666](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/21566661cd703480bb5e58bba9b2b6e1ecb49121))
11
+
1
12
  # [5.0.0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v4.0.0...v5.0.0) (2022-03-01)
2
13
 
3
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-core-theme",
3
- "version": "5.0.0",
3
+ "version": "5.0.1",
4
4
  "description": "Gatsby Theme NPM Package",
5
5
  "main": "index.js",
6
6
  "GATSBY_RECAPTCHA_SITEKEY": "6LfoyvMUAAAAAO4nl_MQnqHb4XdHxEiu5cXgIqeB",
@@ -1,7 +1,7 @@
1
- import React, { useState } from 'react';
1
+ import React, { useState, useEffect } from 'react';
2
2
  // eslint-disable-next-line import/no-extraneous-dependencies
3
3
  import PropTypes from 'prop-types';
4
- import loadable from '@loadable/component';
4
+ import LazyLoad from 'react-lazyload';
5
5
  import { isNativeImageLazyLoadingSupported } from '~helpers/device-detect';
6
6
 
7
7
  export default function LazyImage({
@@ -15,56 +15,44 @@ export default function LazyImage({
15
15
  loading = 'lazy',
16
16
  }) {
17
17
  const [errorImage, setErrorImage] = useState(false);
18
+ const [nonNativeLazyLoaded, setNonNativeLazyLoaded] = useState(false);
19
+
20
+ useEffect(() => {
21
+ setNonNativeLazyLoaded(!isNativeImageLazyLoadingSupported());
22
+ }, []);
18
23
 
19
24
  if ((defaultImg && !src) || errorImage === true) {
20
25
  return defaultImg;
21
26
  }
22
27
 
23
- if (!isNativeImageLazyLoadingSupported()) {
24
- const LazyLoad = loadable(() => import(`react-lazyload`));
25
- return (
26
- <>
27
- <LazyLoad
28
- height={height ? `${height}px` : null}
29
- width={width ? `${width}px` : null}
30
- placeholder={<span className="lazyload-placeholder" />}
31
- debounce={0}
32
- >
33
- <img
34
- src={src}
35
- className={className}
36
- height={height}
37
- width={width}
38
- alt={alt}
39
- style={style}
40
- />
41
- </LazyLoad>
42
- <noscript>
43
- <img
44
- src={src}
45
- className={className}
46
- height={height}
47
- width={width}
48
- alt={alt}
49
- style={style}
50
- />
51
- </noscript>
52
- </>
53
- );
54
- }
55
-
56
- return (
28
+ return !nonNativeLazyLoaded ? (
29
+ <img
30
+ src={src}
31
+ loading={loading}
32
+ className={className}
33
+ height={height}
34
+ width={width}
35
+ alt={alt}
36
+ style={style}
37
+ onError={() => setErrorImage(true)}
38
+ />
39
+ ) : (
57
40
  <>
58
- <img
59
- src={src}
60
- loading={loading}
61
- className={className}
62
- height={height}
63
- width={width}
64
- alt={alt}
65
- style={style}
66
- onError={() => setErrorImage(true)}
67
- />
41
+ <LazyLoad
42
+ height={height ? `${height}px` : null}
43
+ width={width ? `${width}px` : null}
44
+ placeholder={<span className="lazyload-placeholder" />}
45
+ debounce={0}
46
+ >
47
+ <img
48
+ src={src}
49
+ className={className}
50
+ height={height}
51
+ width={width}
52
+ alt={alt}
53
+ style={style}
54
+ />
55
+ </LazyLoad>
68
56
  <noscript>
69
57
  <img
70
58
  src={src}