Skip to content

Fix 'Error: Cannot call impure function during render Math.random is an impure function. Calling an impure function can produce unstable results that update unpredictably when the component happens to re-render. (https://react.dev/reference/rules/components-and-hooks-must-be-pure#components-and-hooks-must-be-idempotent). /app/src/components/ui/sidebar.tsx:643:26 641 | // Random width between 50 to 90%. 642 | const width = React.useMemo(() => { > 643 | return ${Math.floor(Math.random() * 40) + 50}%; | ^^^^^^^^^^^^^ Cannot call impure function 644 | }, []); 645 | 646 | return (' issue in src\components\ui\sidebar.tsx #13

Description

@codefactor-io

CodeFactor found an issue: Error: Cannot call impure function during render

Math.random is an impure function. Calling an impure function can produce unstable results that update unpredictably when the component happens to re-render. (https://react.dev/reference/rules/components-and-hooks-must-be-pure#components-and-hooks-must-be-idempotent).

/app/src/components/ui/sidebar.tsx:643:26
641 | // Random width between 50 to 90%.
642 | const width = React.useMemo(() => {
> 643 | return ${Math.floor(Math.random() * 40) + 50}%;
| ^^^^^^^^^^^^^ Cannot call impure function
644 | }, []);
645 |
646 | return (

It's currently on:
src\components\ui\sidebar.tsx:643
Commit a1ea9eb

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions