Skip to content
Discussion options

You must be logged in to vote

I am not sure Suspense is necessarily made to work like this. Suspense boundaries only trigger when a component suspends, but loading the image does not suspend.

I think you got the right way though. I'd also do it like this:

"use client";

import Image from "next/image";
import { useState } from "react";

export const ImageAsync = ({ src, alt, ...props }) => {
  const [reveal, setReveal] = useState(false);
  const visibility = reveal ? "visible" : "hidden";
  const loader = reveal ? "none" : "inline-block";

  return (
    <div
      style={{
        width: `${props.width}px`,
        height: `${props.height}px`,
        position: "relative",
      }}
    >
      <Image
        src={src}

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
3 replies
@gmcamposano
Comment options

@columk1
Comment options

@trusktr
Comment options

Answer selected by gmcamposano
Comment options

You must be logged in to vote
2 replies
@trusktr
Comment options

@trusktr
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
5 participants