Skip to content

Incorporación de useNearScreen a los Gifs #6

Description

@alvaaz

¿Cómo quedaría el hook useNearScreen para la utilización en los Gifs?
En la implementación de vistas quedaría así:

ListOfGifs.js

 {
      gifs.map(({id, title, url}) =>
        <Gif
          id={id}
          key={id}
          title={title}
          url={url}
        />
      )
    }

Gif.js

export default function Gif ({ title, id, url }) {
  const { isNearScreen, fromRef } = useNearScreen();

  return (
    <div className="Gif" ref={fromRef}>
    {isNearScreen &&
      <Link to={`/gif/${id}`} className='Gif-link'>
        <h4>{title}</h4>
        <img loading='lazy' alt={title} src={url} />
      </Link>
     }
    </div>

  )
}

Pero esto repetiría el useScreenNear por cada Gif, ¿como poder utilizar el argumento de entries para observar a todos los gif sin tener que repetir todo el hook por cada Gif?.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions