JavaScript
- 6 ответов
- 0 вопросов
3
Вклад в тег
const App = () => {
const size = useWindowSize()
const [width, setWidth] = useState(null)
const [height, setHeight] = useState(null)
const [direction, setDirection] = useState(null)
useEffect(() => {
if (size.width > 1200) {
setWidth('500px')
setHeight('300px')
setDirection('row')
} else if (size.width > 900 && size.width <= 1200) {
setWidth('100%')
setHeight('250px')
setDirection('column')
}
} else return
}, [ size.width ])
// yourCodeHere
}
// Потом в стилях задаете:
text_block: {
width: width
height: height,
display: 'flex',
flexDirection: direction
}