Skip to content

useFacetEffect will never fire if there are no facet dependencies #88

@xaviervia

Description

@xaviervia

Right now, if we run:

useFacetEffect(() => { console.log('I will never fire' }, [], [])

The effect will never fire, because useFacetEffect expects for all facets to resolve to a value before firing the effect. In this case, there are no facets to resolve in the second dependency array, so it will just never fire at all.

In a way this scenario doesn't make sense (we should use useEffect instead) but since there's no way to enforce that empty arrays are not allowed, we should fail gracefully. Instead of never firing, useFacetEffect with an empty facet array should just behave in exactly the same way as a regular useEffect. This, we think, would be the expected behavior.

This issue applies also to a similar scenario in useFacetCallback. We should fix that one as well in the same way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions