Last active
February 13, 2020 11:47
-
-
Save ademilter/0e9be28fde5cb451ed606437f2db062d to your computer and use it in GitHub Desktop.
use flickity with gastby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"dependencies": { | |
"flickity": "^2.2.1" | |
"react-flickity-component": "^3.5.0" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import 'flickity/dist/flickity.css' | |
const Slider = ({ children, options, ...props }) => { | |
const Flickity = | |
typeof window !== 'undefined' | |
? require('react-flickity-component') | |
: () => null | |
return ( | |
Flickity && ( | |
<Flickity options={options} {...props}> | |
{children} | |
</Flickity> | |
) | |
) | |
} | |
Slider.defaultProps = { | |
options: { | |
pageDots: false, | |
prevNextButtons: false, | |
cellAlign: 'left', | |
contain: true, | |
selectedAttraction: 0.2, | |
friction: 0.8 | |
} | |
} | |
export default Slider |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if you are using nextjs check here
https://nextjs.org/docs/advanced-features/dynamic-import#basic-usage