Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function Banner() {
const [index, set] = useState(0);
const [backgroundInterval, setBackgroundInterval] = useState();
const transitions = useTransition(slides[index], item => item.id, {
from: { opacity: 0 },
enter: { opacity: 1 },
leave: { opacity: 0 },
config: config.molasses
});
useEffect(() => {
setBackgroundInterval(setInterval(() => set(state => (state + 1) % 2), 6000));
return function cleanup() {
clearInterval(backgroundInterval);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return (
<div>
{transitions.map(({ item, props, key }) => (
<>
<div>
</div></div>
export const RewindSpringProvider = function({children}) {
const [flip, set] = useState(false)
const animatedProps = useSpring({
reset: true,
reverse: flip,
from: {x: 0},
x: 1,
delay: 200,
config: config.molasses,
onRest: () => set(!flip)
})
return (
<div>
</div>
)
}
export default function App() {
const [index, set] = useState(0)
const transitions = useTransition(slides[index], item => item.id, {
from: { opacity: 0 },
enter: { opacity: 1 },
leave: { opacity: 0 },
config: config.molasses,
})
useEffect(() => {
const id = setInterval(() => set(state => ++state % slides.length), 2000)
return () => clearInterval(id)
}, [])
return transitions.map(({ item, props, key }) => (
))
}
const MobileVersion = ({ items, ...rest }) => {
const [index, set] = useState(0)
const itemsWithKeys = items.map((item, key) => ({
...item,
key
}))
const transitions = useTransition(itemsWithKeys[index], (item) => item.key, {
from: { opacity: 0 },
enter: { opacity: 1 },
leave: { opacity: 0 },
config: config.molasses
})
const delay = itemsWithKeys.length > 3 ? 3200 : 4200
useEffect(
() =>
void setInterval(
() => set((state) => (state + 1) % itemsWithKeys.length),
delay
),
[]
)
return (
{transitions.map(({ item, props, key }) => (
const Carousel: React.FunctionComponent = () => {
const [items] = useState([
{ title: 'GraphQL changed the way we create software', id: 0 },
{ title: 'Learn about GraphQL language for free in the browser', id: 1 },
{ title: 'Learn how to be Lead frontend engineer with GraphQL driven React and Apollo applications', id: 2 },
]);
const [index, setIndex] = useState(0);
const heightProps = useSpring({
config: config.slow,
from: { height: '0px' },
to: { height: '700px' },
});
const opacityProps = useSpring({
config: config.molasses,
delay: 400,
from: { opacity: 0 },
to: { opacity: 1 },
});
const fadingTextPropsTransition = useTransition(items[index], (item) => item.id, {
from: { opacity: 0 },
enter: { opacity: 1 },
leave: { opacity: 0 },
config: { tension: 220, friction: 120 },
});
useEffect(() => {
const interval = setInterval(() => {
setIndex((state) => (state + 1) % items.length);
}, 4000);
const Icon = (props) => {
return (
{styles => (
)}
);
}