Skip to content

Using Slots without a context prop results an infinite render loop #2187

Closed
@iansan5653

Description

@iansan5653

The context prop on the Slots component generated by createSlots is marked as optional:

context?: ContextProps['context']

However, not providing this prop causes an infinite render loop. The result will look fine, but a check of the console will show that it never stops rendering:

Error: 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.

This bug is really hard to figure out since there's no hints as to what causes the issue.

Even just setting the prop to an empty object (<Slots context={{}}>) fixes the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreact

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions