Reputation: 1751
This code works:
<Swiper
breakpoings={{
400: {
// config
}
}}
But this code does not work:
const sm = 400;
<Swiper
breakpoings={{
sm: {
// config
}
}}
Why it's so? How can I use variables in Swiper's breakpoints in React?
Upvotes: 0
Views: 273
Reputation: 1301
When you want to name object key by variable you need to wrap it in square brackets.
const sm = 400;
<Swiper
breakpoints={{
[sm]: {
// config
}
}}
Upvotes: 1