loktar00 / react-lazy-load

React component that renders children elements when they enter the viewport.
MIT License
979 stars 166 forks source link

Wrap image with <span> instead of <div> #125

Closed mario-iliev closed 2 years ago

mario-iliev commented 6 years ago

I'm parsing content from REST API and images are placed in paragraphs. Since Div in Paragraph is invalid and React is logging "Warning: validateDOMNesting(...): < div > cannot appear as a descendant of < p >." Personally I would prefer to use < img > with transparent base64 src until it's loaded, and don't use any extra wrappers.

kianfang commented 6 years ago

Try to use "elementType" props, eg:

import React from 'react';
import LazyLoad from 'react-lazy-load';

<LazyLoad elementType="span">
    <img src"/path" />
</LazyLoad>