Skip to content

Design deficiency with rapidly changing states #5

@drinking-code

Description

@drinking-code

A state listener like this

doSomething((myElement, [myState, setMyState]) => {
    const mouseOverHandler = e => {
        setMyState(/* some always changing value */)
    }
    myElement.addEventListener('mouseover', mouseOverHandler)
    return () => {
        myElement.removeEventListener('mouseover', mouseOverHandler)
    }
}, [myElement, myState])

is constantly being re-called, even though it does not have to be. Requiring the state in the statesAndRefs array (to use the setState function) does not imply the usage of the state's value.
Providing the option to use a setState without listening to state changes will drastically improve performance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions