C
C
cyberlain2022-02-08 09:47:11
React
cyberlain, 2022-02-08 09:47:11

How to make the transition to the next slide on a given event?

There is a slider . There is an input outside the slider. How can I make the scroll forward function work when entering a certain word in the input?

const check =() => {какая-то магия}
return(
<input type="text" onKeyUp="check">
<swiper>
)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2022-02-08
@cyberlain

const [ text, setText ] = useState('');
const [ swiper, setSwiper ] = useState(null);

useEffect(() => {
  if (swiper && text какой там вам нужен) {
    swiper.slideNext();
  }
}, [ swiper, text ]);

<Swiper
  onSwiper={setSwiper}
  ...

<input
  value={text}
  onChange={e => setText(e.target.value)}
  ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question