facebook / docusaurus

Easy to maintain open source documentation websites.
https://docusaurus.io
MIT License
54.07k stars 8.1k forks source link

Ideal image flashing when navigating back and forward #10214

Open Legend-Master opened 3 weeks ago

Legend-Master commented 3 weeks ago

Have you read the Contributing Guidelines on issues?

Prerequisites

Description

Image flashing when navigating back and forward using Ideal Image

A possible fix would be to use browser native image lazy loading <img loading="lazy"> instead of react-ideal-image (also posted in https://docusaurus.io/feature-requests/p/use-browser-lazy-loading-in-plugin-ideal-image)

Swizzling code I'm currently using to avoid this problem ```ts export default function IdealImage(props: Props): JSX.Element { const { img, ...propsRest } = props // In dev env just use regular img with original file if (typeof img === 'string' || 'default' in img) { return ( // eslint-disable-next-line jsx-a11y/alt-text ) } return ( ) } ```

Reproducible demo

No response

Steps to reproduce

  1. Go to https://docusaurus.io/docs/playground
  2. Navigate to another page
  3. Navigate back

Expected behavior

No flashing

Actual behavior

Flashing

https://github.com/facebook/docusaurus/assets/68118705/8285459b-0711-4a6b-ba89-d24d64eccf04

image

Your environment

Self-service