Skip to content

useWindowDimensions causes infinite re-rendering #26733

@ShaMan123

Description

@ShaMan123

Using useWindowDimensions causes the app to re-render infinitly.
I have no idea why.
I copied the source code to my app and used it without any issues.
Once I use the exported hook this issue resumes.
Running on android.

React Native version: 0.61.2

System:
    OS: Windows 10
    CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
    Memory: 665.92 MB / 7.87 GB
  Binaries:
    Node: 8.16.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.17.3 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.10.1 - C:\Program Files\nodejs\npm.CMD
  SDKs:
    Android SDK:
      Android NDK: 17.2.4988734
  IDEs:
    Android Studio: Version  3.5.0.0 AI-191.8026.42.35.5791312

Steps To Reproduce

  1. import useWindowDimensions
  2. use it inside a function component or custom hook

Describe what you expected to happen:
use the hook without any issues.

Snack, code example, screenshot, or link to a repository:

 ▶︎ 'Warning: Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn\'t have a dependency array, or one of the dependencies changes on every render.%s', 

Metadata

Metadata

Assignees

No one assigned

    Labels

    API: DimensionsBugStaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions