跳至主要内容

1 篇文章 含有標籤「responsive」

檢視所有標籤

How to Get Window Size in React (The Right Way)

· 閱讀時間約 4 分鐘

Responsive design doesn't stop at CSS. Sooner or later, you need the actual window width or height inside your React component — to conditionally render a sidebar, swap a chart library between mobile and desktop, or calculate a dynamic layout. Getting that value correctly, especially with server-side rendering in the mix, is trickier than it looks.