Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

useWindowSize does not work on App Router (nextjs)

Đang mở
#2,532 2 bình luận 6 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
38/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
nextjs, react, typescript
Lĩnh vực
frontend, web-dev

Hướng nghiên cứu

Start by reproducing the reported hydration warning with Next.js 14 App Router and the useWindowSize entry point shown in the issue. Compare the server and browser results, then verify that the hook returns the browser's window dimensions without a width mismatch.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

What is the current behavior?

Gives an error:
app-index.js:32 Warning: Prop width did not match. Server: "Infinity" Client: "1290"

This is probably due to app router running the code on server side even with "use client" specified.

Steps to reproduce it and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have extra dependencies other than react-use. Paste the link to your JSFiddle or CodeSandbox example below:

  • install nextjs 14
  • use app router
  • create a component
"use client";

import useWindowSize from "react-use/lib/useWindowSize";

const StepSubmittedWidget = () => {
  const { width, height } = useWindowSize();

return (<></>)
}

export default StepSubmittedWidget;

What is the expected behavior?

Gives the browser's window sizes

A little about versions:

  • OS: MacOS
  • Browser (vendor and version): Chrome
  • React: 18.2.0
  • react-use: 17.4.2
  • Did this worked in the previous package version? No
Ngôn ngữ chính
TypeScript
Star
44k
Fork
3.3k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của streamich/react-use

Tất cả issue của streamich/react-use

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.