react-lazyload icon indicating copy to clipboard operation
react-lazyload copied to clipboard

pass className to the wrapper span so that it can be styled

Open ucarbehlul opened this issue 5 years ago • 3 comments
trafficstars

using styled components or by some other common css classes.

ucarbehlul avatar Jun 26 '20 22:06 ucarbehlul

@ucarbehlul I'm unable to understand the problem, can you please elaborate

ameerthehacker avatar Jun 27 '20 07:06 ameerthehacker

@ucarbehlul I'm unable to understand the problem, can you please elaborate

Some elements like adsense <ins> element needs parent container to have some width to be responsive. We can use the lazy-load element in below way to easily fix that issue:

import styled from 'styled-components'

const Wrapper = styled(LazyLoad)`
  width: 100%;
  @media (min-width: 576px) {
      display:none
  }
`;

if we don't use passed className prop styled components would not work. There may be other solutions to this problem but this is the most straightforward one if you are using styled components already.

ucarbehlul avatar Jun 27 '20 18:06 ucarbehlul

@ucarbehlul @ameerthehacker This feature would be extremely useful, we have no way of passing a custom class to the wrapper.

I'm also using styled components so this would help, a lot.

joerdav avatar Jul 27 '20 15:07 joerdav