【问题标题】:Why is my react-lightbox not going full screen in next.js为什么我的 react-lightbox 在 next.js 中没有全屏显示
【发布时间】:2022-10-20 18:22:34
【问题描述】:

我正在使用 next.js,我希望在点击我的一张图片时看到像 这样的画廊收藏,但没有发生。实际上,这就像我刚刚使用了一个普通组件一样,因为当我单击其中一张图像时,实际上什么都没有发生。请帮忙。

// this  is my app component

import SimpleReactLightbox from 'simple-react-lightbox'

const MyApp = ()=>{
  return(
    <SimpleReactLightbox>
     <Component {...pageProps} />
    </SimpleReactLightbox>
  )
}

// this is my collection

import { CollectionStyledTypography } from './styles/collectionStyledComponents'
import { SRLWrapper } from 'simple-react-lightbox'
import Image from 'next/image'

const Collection = ({ imagesList = [] }) => {
  return (
    <SRLWrapper>
      <div style={{ margin: '50px' }}>
        {imagesList.map((image, index) => (
          <CollectionStyledTypography component="div" key={index}>
            <Image src={image.src} alt={image.alt} layout="fill" />
          </CollectionStyledTypography>
        ))}
      </div>
    </SRLWrapper>
  )
}
export default Collection

【问题讨论】:

    标签: next.js


    【解决方案1】:

    SRL 不再被开发,它在 React 18 中不起作用。您必须降级到 17 才能使其工作。我面临同样的问题,当我点击图像时没有任何反应。

    【讨论】:

      猜你喜欢
      • 2021-07-22
      • 2017-10-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-09
      • 1970-01-01
      • 2020-07-25
      相关资源
      最近更新 更多