Skip to content

How to call an image fetching function on next/previous slide click and await the response #228

Closed Locked Answered by igordanchenko
JPVRS asked this question in Q&A
Discussion options

You must be logged in to vote

Hi there!

Here is how you can approach this problem:

  1. Fill the initial slides array with placeholder slides { src: "" } (empty src string being a placeholder marker)
  2. Define a custom render function and render placeholder image / loading indicator
  3. Subscribe to the view event and implement your image fetching logic here; update slides array with the loaded image

Here is a proof-of-concept implementation - https://codesandbox.io/p/devbox/yet-another-react-lightbox-228-cyyv8r?file=%2Fsrc%2FApp.tsx

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@igordanchenko
Comment options

Answer selected by igordanchenko
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
Q&A
Labels
None yet
2 participants