我接管了一个React项目,正在笨拙地将react-share与react-image-lightbox结合起来。我对React
和Typescript
都不太熟悉,所以任何见解都非常感谢。
下面是相关的代码片段:
import {
FacebookShareButton,
GooglePlusShareButton,
LinkedinShareButton,
TwitterShareButton,
EmailShareButton,
} from 'react-share'
const Lightbox = require('react-image-lightbox')
render() {
return(
<Lightbox
...
toolbarButtons={['Facebook share button?', 'Twitter share button?']}
...
onCloseRequest={this.handleCloseViewer}
onMovePrevRequest={this.handleViewPrev}
onMoveNextRequest={this.handleViewNext}
/>
)
}
发布于 2018-05-31 07:10:47
解决了:这是工作片段。
import {
FacebookShareButton,
GooglePlusShareButton,
LinkedinShareButton,
TwitterShareButton,
EmailShareButton,
} from 'react-share'
import {
FacebookIcon,
TwitterIcon,
PinterestIcon,
EmailIcon
} from 'react-share';
const Lightbox = require('react-image-lightbox')
render() {
return(
<Lightbox
...
toolbarButtons={[
<FacebookShareButton url={window.location.href} children={<FacebookIcon size={32} round={true} />} />,
<TwitterShareButton url={window.location.href} children={<TwitterIcon size={32} round={true} />} />,
<PinterestShareButton url={window.location.href} children={<PinterestIcon size={32} round={true} />} />,
<EmailShareButton url={window.location.href} children={<EmailIcon size={32} round={true} />} />
]}
...
onCloseRequest={this.handleCloseViewer}
onMovePrevRequest={this.handleViewPrev}
onMoveNextRequest={this.handleViewNext}
/>
)
}
https://stackoverflow.com/questions/50593304
复制相似问题