Giter VIP home page Giter VIP logo

wellyshen / react-cool-img Goto Github PK

View Code? Open in Web Editor NEW
779.0 3.0 29.0 12.29 MB

😎 🏞 A React <Img /> component let you handle image UX and performance as a Pro!

Home Page: https://react-cool-img.netlify.app

License: MIT License

JavaScript 5.87% TypeScript 81.67% Shell 0.32% HTML 7.20% SCSS 4.93%
react ui img placeholder lazy-loading auto-retry component intersection-observer performance-optimization ssr

react-cool-img's Introduction

REACT COOL IMG

This is a lightweight React <Img /> component, which helps you handle image UX (user experience) and performance optimization as a professional guy πŸ€“

It empowers the standard img tag by many cool features without breaking your original development experience. Ideally, it can be an img tag replacement for React.js.

⚑️ Live demo: https://react-cool-img.netlify.app

❀️ it? ⭐️ it on GitHub or Tweet about it.

build status coverage status npm version npm downloads npm downloads gzip size All Contributors PRs welcome Twitter URL

Features

⚠️ Most modern browsers support Intersection Observer natively. You can also add polyfill for full browser support.

Requirement

react-cool-img is based on React Hooks. It requires react v16.8+.

Installation

This package is distributed via npm.

$ yarn add react-cool-img
# or
$ npm install --save react-cool-img

Quick Start

The default props of the component has been fine-tuned for the purpose of loading optimization. Let's start it as the following example.

import Img from "react-cool-img";

// Suggest to use low quality or vector images
import loadingImage from "./images/loading.gif";
import errorImage from "./images/error.svg";

const App = () => (
  <Img
    placeholder={loadingImage}
    src="https://the-image-url"
    error={errorImage}
    alt="REACT COOL IMG"
  />
);

Don't want an image placeholder? No worries, you can use inline styles or CSS for it. The component is fully compatible with the development experience of normal img tag.

import Img from "react-cool-img";

const App = () => (
  <Img
    style={{ backgroundColor: "grey", width: "480", height: "320" }}
    src="https://the-image-url"
    alt="REACT COOL IMG"
  />
);

API

The image component working similar with standard img tag and with the following props.

Prop Type Default Description
src string Image source. It's required.
Support formats
srcSet string Image sources for responsive images. For src prop only.
Reference article
sizes string Image sizes for responsive images. For src prop only.
Reference article
width string Width of the image in px.
height string Height of the image in px.
placeholder string Placeholder image source.
Support formats
error string Error image source. It'll replace Placeholder image.
Support formats
alt string An alternate text for an image section.
decode boolean true Use img.decode() to pre-decode the image before render it. Useful to prevent main thread from blocking by decoding of large image.
lazy boolean true Turn on/off lazy loading.
Using Intersection Observer
cache boolean true Instantly load images which have been cached when possible to abort the lazy loading behavior.
Reference article
debounce number 300 How much to wait in milliseconds that the image has to be in viewport before starting to load. This can prevent images from being downloaded while the user scrolls quickly past them.
observerOptions object { root: window, rootMargin: '50px', threshold: 0.01 } See the observerOptions section.
retry object { count: 3, delay: 2, acc: '*' } See the retry section.
... Find more props and events.

observerOptions

All the properties are optional.

  • root: Element | null - the element that is used as the viewport for checking visibility of the target. Must be the ancestor of the target. Defaults to the browser viewport if not specified or if null.
  • rootMargin: string - margin around the root. Can have values similar to the CSS margin property, e.g. "10px 20px 30px 40px" (top, right, bottom, left). The values can be percentages. This set of values serves to grow or shrink each side of the root element's bounding box before computing intersections.
  • threshold: number - a single number between 0 and 1, which indicate at what percentage of the target's visibility the observer's callback should be executed. A value of 0 means as soon as even one pixel is visible, the callback will be run. 1 means that the threshold isn't considered passed until every pixel is visible.

retry

All the properties are optional.

  • count: number - specifies the number of times you want to retry. Set it to 0 will disable auto-retry.
  • delay: number - specifies the delay between retries in seconds.
  • acc: string | false - specifies how the delay should be accumulated with each retry. It accepts the following values:
    • '*' (default) - multiply delay after each subsequent retry by the given delay value, e.g. delay: 2 means retry will run after 2 seconds, 4 seconds, 8 seconds, and so on.
    • '+' - increment delay after each retry by the given delay value, e.g. delay: 2 means retry will run after 2 seconds, 4 seconds, 6 seconds, and so on.
    • false - keep the delay constant between retries, e.g. delay: 2 means retry will run every 2 seconds.

The Smart Way to Load Images

Lazy image loading via the Intersection Observer API is good. But could it be greater to download an image only when user want to see it? Or bypass lazy loading for cached images? The answer is yes and these features already be built into react-cool-img by the debounce and cache props.

By the debounce prop, an image can wait to be downloaded while it's in the viewport for a set time. In cases where you have a long list of images that the user might scroll through inadvertently. At this time loading images can cause unnecessary waste of bandwidth and processing time.

import Img from "react-cool-img";

import defaultImg from "./images/default.svg";

const App = () => (
  <Img
    placeholder={defaultImg}
    src="https://the-image-url"
    debounce={1000} // Default is 300 (ms)
    alt="REACT COOL IMG"
  />
);

By the cache prop, images you already have cached will abort lazy loading until user visit your app next time. Lazy loading is set up for any remaining images which were not cached. This is helpful for UX, because there's not much extra work to load cached images immediately and is an easy win for making the UI looks more intuitive.

import Img from "react-cool-img";

import defaultImg from "./images/default.svg";

const App = () => (
  <Img
    placeholder={defaultImg}
    src="https://the-image-url"
    cache // Default is true, just for demo
    alt="REACT COOL IMG"
  />
);

JavaScript Availability and SEO

There're two challenges when doing lazy image loading with server-side rendering. One is Javascript availability the other is SEO. Fortunately, we can use <noscript> tag to solve these problems. It will render the actual image as fallback if Javascript is disabled thus user won't see the image which be stuck with the placeholder. Moreover, the <noscript> tag ensure the image is indexed by search engine bots even if they cannot fully understand our JavaScript code. Take a look at how magic happens.

// src/Img.tsx

const Img = () => {
  // ...

  return (
    <>
      <img
        class="image"
        src="https://the-placeholder-image"
        alt="There's no magic"
      />
      <noscript>
        <img
          class="image"
          src="https://the-actual-image"
          alt="The magic begins in here..."
        />
      </noscript>
    </>
  );
};

Intersection Observer Polyfill

Intersection Observer has good support amongst browsers, but it's not universal. You'll need to polyfill browsers that don't support it. Polyfills is something you should do consciously at the application level. Therefore react-cool-img doesn't include it.

You can use W3C's polyfill:

$ yarn add intersection-observer
# or
$ npm install --save intersection-observer

Then import it at your app's entry point:

import "intersection-observer";

Or use dynamic imports to only load the file when the polyfill is required:

(async () => {
  if (!("IntersectionObserver" in window))
    await import("intersection-observer");
})();

Polyfill.io is an alternative way to add the polyfill when needed.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Welly

πŸ’» πŸ“– 🚧

This project follows the all-contributors specification. Contributions of any kind welcome!

react-cool-img's People

Contributors

allcontributors[bot] avatar dependabot-preview[bot] avatar dependabot[bot] avatar greenkeeper[bot] avatar renovate-bot avatar wellyshen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-cool-img's Issues

Lazy loading isn't working although lazy attribute is true

Bug Report

Describe the Bug

A clear and concise description of what the bug is.

How to Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

const fields: JSX.Element[] = [];
for (let i = 1; i <= 800; i++) {
fields.push(
<AspectRatio ratio="1" style={{ maxWidth: "200px" }}>
{/source = {content.moodImage?.previews.s}/}
<Img
key={i}
src={https://source.unsplash.com/random/?image=${i}}
style={{ backgroundColor: "grey", width: "480", height: "320" }}
alt="REACT COOL IMG"
cache
lazy
debounce={1000}
/>

);
}

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function TestPageImages(): JSX.Element {
return (
<>
<AspectRatio ratio="1/5" style={{ maxWidth: "400px" }}>
<img key={"key"} src={"https://source.unsplash.com/random"} alt="REACT COOL IMG" />

{fields}

</>
);
}

Expected Behavior

It should load lazy the images while scrolling, but it loads every single image at the beginning.

Screenshots

Your Environment

  • Device: MacBook Pro
  • OS: macOS
  • Browser: Chrome

An in-range update of @types/react is breaking the build 🚨

The devDependency @types/react was updated from 16.9.14 to 16.9.15.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@types/react is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of @types/react is breaking the build 🚨

The devDependency @types/react was updated from 16.9.13 to 16.9.14.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@types/react is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of @types/react is breaking the build 🚨

The devDependency @types/react was updated from 16.9.12 to 16.9.13.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@types/react is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Check if the browser supports IntersectionObserver conditions are not enough

Hi, on Chorme 57, window.IntersectionObserver exists but entry.isIntersecting is always undefined. Please add like below to prevent lazy loading. In order to use isIntersecting normally.

if (
  !window.IntersectionObserver ||
  (window.IntersectionObserverEntry && !('isIntersecting' in window.IntersectionObserverEntry.prototype)))
) {
  console.error(observerErr)
  return (): void => null
}

Use url in placeholder

I know this is probably gonna get closed, but i still want to ask you.
Is there any way i can use image url as a value for placeholder?
Thank you

An in-range update of eslint-plugin-import is breaking the build 🚨

The devDependency eslint-plugin-import was updated from 2.18.2 to 2.19.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint-plugin-import is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 46 commits.

  • 9b76635 Bump to v2.19.0
  • 47a232e [resolvers/webpack] v0.12.0
  • 26ad476 [resolvers/webpack] [deps] update debug, enhanced-resolve, has, interpret, lodash, resolve, semver
  • 3f0e8f3 [resolvers/node] [Deps] update resolve
  • 7190c3e bump utils to v2.5.0
  • a60e5c6 [New] no-commonjs: add allowConditionalRequire option
  • 414c923 [New] enable passing cwd as an option to eslint-import-resolver-webpack
  • 8224e51 [New] order/no-extraneous-dependencies: Alphabetize imports within groups
  • f12ae59 [New] no-duplicates: add a considerQueryString option to handle false positives when using some webpack loaders.
  • 2d3d045 [fix] importType: Accept '@example' as internal
  • 0426f16 [New] order: add pathGroups option to add support to order by paths
  • 99b3fbf [Fix] no-extraneous-dependencies: Add support for export from
  • 21bf8c6 [Fix] no-cycle: should not warn for Flow imports
  • 0cd5e43 [Fix] no-unused-modules: fix crash due to export *
  • 05085bb [flow] no-unused-modules: add flow type support

There are 46 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

this.img.decode is not a function

Bug Report

Describe the Bug

Hi,
getting the error in Android:
this.img.decode is not a function
User Agent:
Mozilla/5.0 (Linux; U; Android 9; zh-CN; MZ-16s Pro Build/MRA58K) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/62.0.3202.97 MZBrowser/8.7.0 Mobile Safari/537.36

When I change another browser ,no error but get blank img
Quark browser User Agent:
Mozilla/5.0 (Linux; U; Android 9; zh-CN; 16s Pro Build/PKQ1.190616.001) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.108 Quark/3.8.5.129 Mobile Safari/537.36

Additional Information

console.log(window.IntersectionObserver) has value

An in-range update of @types/react is breaking the build 🚨

The devDependency @types/react was updated from 16.9.16 to 16.9.17.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@types/react is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Getting the error in Internet Explorer after implementing intersection-observer polyfill.

As per the steps in repo, implemented the react-cool-img with intersection-observer polyfill for internet explorer, than getting below error message.

!react-cool-img: the browser doesn't support Intersection Observer, please install polyfill to enable lazy loading: https://github.com/wellyshen/react-cool-img#intersection-observer-polyfill

Screenshot 2020-05-28 at 5 49 51 PM

Use Case Scenario:

Used within react application, and defined it in app entry point as below
import 'intersection-observer'

Getting above error messages in console.

And only placeholder image is shown in IE, the real image never shows up.

Is the usage done is correct ?? Or is there is something missing

An in-range update of eslint is breaking the build 🚨

The devDependency eslint was updated from 6.7.0 to 6.7.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for v6.7.1
  • dd1e9f4 Fix: revert changes to key-spacing due to regression (#12598) (Kai Cataldo)
  • c644b54 Docs: Update README team and sponsors (ESLint Jenkins)
Commits

The new version differs by 4 commits.

  • af95154 6.7.1
  • 9361824 Build: changelog update for 6.7.1
  • dd1e9f4 Fix: revert changes to key-spacing due to regression (#12598)
  • c644b54 Docs: Update README team and sponsors

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of @typescript-eslint/eslint-plugin is breaking the build 🚨

The devDependency @typescript-eslint/eslint-plugin was updated from 2.9.0 to 2.10.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@typescript-eslint/eslint-plugin is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for v2.10.0

2.10.0 (2019-12-02)

Bug Fixes

  • eslint-plugin: [no-empty-function] add missed node types (#1271) (e9d44f5)
  • eslint-plugin: [no-untyped-pub-sig] ignore set return (#1264) (6daff10)
  • eslint-plugin: [no-unused-expressions] ignore directives (#1285) (ce4c803)
  • eslint-plugin: [prefer-optional-chain] allow $ in identifiers (c72c3c1)
  • eslint-plugin: [prefer-optional-chain] handle more cases (#1261) (57ddba3)
  • eslint-plugin: [return-await] allow Any and Unknown (#1270) (ebf5e0a)
  • eslint-plugin: [strict-bool-expr] allow nullish coalescing (#1275) (3b39340)
  • typescript-estree: make FunctionDeclaration.body non-null (#1288) (dc73510)

Features

  • eslint-plugin: [no-empty-func] private/protected construct (#1267) (3b931ac)
  • eslint-plugin: [no-non-null-assert] add suggestion fixer (#1260) (e350a21)
  • eslint-plugin: [no-unnec-cond] support nullish coalescing (#1148) (96ef1e7)
  • eslint-plugin: [prefer-null-coal] opt for suggestion fixer (#1272) (f84eb96)
  • experimental-utils: add isSpaceBetween declaration to Sou… (#1268) (f83f04b)
Commits

The new version differs by 16 commits.

  • 5adb8a2 chore: publish v2.10.0
  • 065393b docs(eslint-plugin): typo in the configs README (#1295)
  • 96ef1e7 feat(eslint-plugin): [no-unnec-cond] support nullish coalescing (#1148)
  • e350a21 feat(eslint-plugin): [no-non-null-assert] add suggestion fixer (#1260)
  • ce4c803 fix(eslint-plugin): [no-unused-expressions] ignore directives (#1285)
  • f84eb96 feat(eslint-plugin): [prefer-null-coal] opt for suggestion fixer (#1272)
  • dc73510 fix(typescript-estree): make FunctionDeclaration.body non-null (#1288)
  • 3b39340 fix(eslint-plugin): [strict-bool-expr] allow nullish coalescing (#1275)
  • ebf5e0a fix(eslint-plugin): [return-await] allow Any and Unknown (#1270)
  • e9d44f5 fix(eslint-plugin): [no-empty-function] add missed node types (#1271)
  • 3b931ac feat(eslint-plugin): [no-empty-func] private/protected construct (#1267)
  • c72c3c1 fix(eslint-plugin): [prefer-optional-chain] allow $ in identifiers
  • f83f04b feat(experimental-utils): add isSpaceBetween declaration to Sou… (#1268)
  • 57ddba3 fix(eslint-plugin): [prefer-optional-chain] handle more cases (#1261)
  • 6daff10 fix(eslint-plugin): [no-untyped-pub-sig] ignore set return (#1264)

There are 16 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Can I get the img ref?

Hi, when I try to use ref prop to handle image get the error:Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()

Adding picture tag support to use WebP with a legacy format failover

Feature Request

Describe the Feature

I absolutely love react-cool-img. Thanks!

I recently explored ways to improve load times and stumbled upon WebP.

Problem is WebP is not supported by Safari on macOS Catalina and bellow (and some other legacy browsers).

According to Google docs, using picture tags is the recommended approach to fallback to legacy src on legacy browsers.

It would be amazing if react-cool-img used picture tags and allowed us to provide multiple src and placeholder props.

Perhaps src and placeholder could be either a string which would make the codebase backwards compatible or a string[] which could use all but last string items as source tags (type could be derived from file extension) and last item as failover img tag.

import Img from "react-cool-img";

const App = () => (
  <Img
    placeholder={["/path/to/placeholder.webp", "/path/to/placeholder.png"]}
    src={["/path/to/image.webp", "/path/to/image.png"]}
  />
);
<picture>
  <source type="image/webp" srcset="/path/to/image.webp">
  <img src="/path/to/image.png">
</picture>

Describe the Solution You'd Like

See above…

Describe Alternatives You've Considered

I considered using JavaScript (see Google docs) to detect if WebP is supported. Problem is that approach is async therefore not the best from a performance standpoint.

TypeError: Cannot set property 'current' of null

Error From Cool-Img
ref
node_modules/react-cool-img/dist/index.esm.js:311

  308 |     setRef(el); // @ts-expect-error
  309 |     // eslint-disable-next-line no-param-reassign
  310 | 
> 311 |     _ref2.current = el;
      | ^  312 |   }
  313 | })), /*#__PURE__*/React.createElement("noscript", null, /*#__PURE__*/React.createElement("style", null, ".no-js-" + filename + " { display: none !important; }"), /*#__PURE__*/React.createElement("img", _extends({
  314 |   className: className,

commitAttachRef
node_modules/react-dom/cjs/react-dom.development.js:20023

  20020 | } // Moved outside to ensure DCE works with this flag
  20021 | 
  20022 | if (typeof ref === 'function') {
> 20023 |   ref(instanceToUse);
        | ^  20024 | } else {
  20025 |   {
  20026 |     if (!ref.hasOwnProperty('current')) {

There are many requests at the beginning

Bug Report

Describe the Bug

There are in spite of lazy loading a lot of API calls at the beginning, as the DOM elements are still very small and are therefore in the view port.

How to Reproduce

This "bug" appears also on your netlify app.

CodeSandbox Link

Show me the bug on CodeSandbox.

Expected Behavior

I would like to see the API calls after the page load, so that there are less API calls at the beginning.

Screenshots

Add screenshots to help explain your problem.

Your Environment

  • Device: MacBook Pro
  • OS: macOS
  • Browser: Chrome

Additional Information

Any other information about the problem here.

An in-range update of emotion is breaking the build 🚨

There have been updates to the emotion monorepo:

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

This monorepo update includes releases of one or more dependencies which all belong to the emotion group definition.

emotion is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Custom key for image cache.

Feature Request

Allow to provide custom key for image caching.

Describe the Feature

We're using this library with images that comes from a cloud storage and in these URL its included the token to allow download it. That token changes from time to time, then the images aren't getting effectively cached.

Describe the Solution You'd Like

Have a prop to provide the key I want to assign to an image for its cache. Then I can pass there the URL without the token. And all load attempts with different token will result on same cached image.

Describe Alternatives You've Considered

I've considered trying to have same token during user instance but it's something not doable right now. I've also considered creating a page on my site to act as intermediary, for the shake of having a url that don't changes with SAS token.

Additional Information

I am using your library + react + azure blob storage, with urls secured by SAS tokens.

<Img/> is `any` type because of wrong type definition

Bug Report

Describe the Bug

Img element is any type that prevents auto completion.

Expected Behavior

Img should have a valid type definition.

Screenshots

vscode

Your Environment

  • Device: Desktop PC
  • OS: Windows 11
  • Runtime: Node.js v16.16.0
  • Version: v1.2.12

Additional Information

Here is Img 's definition:

const Img: ForwardRefExoticComponent<HTMLImageElement, ImgProps>;

But react.ForwardRefExoticComponent accepts only one type argument.

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/72c1299e1ad143a84b900f7435c8b9f5f04a1d3e/types/react/index.d.ts#L773-L778

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.