Skip to content

state_reference_locally warning message is unclear #13079

Closed
@sacrosanctic

Description

@sacrosanctic

Describe the bug

/**
* State referenced in its own scope will never update. Did you mean to reference it inside a closure?
* @param {null | NodeLike} node
*/
export function state_referenced_locally(node) {
w(node, "state_referenced_locally", "State referenced in its own scope will never update. Did you mean to reference it inside a closure?");
}

"How to use a closure?" was asked several times in discord. In addition, closure only refers to functions where classes also serve the same purpose.

I propose an update to the message
"State referenced in its own scope will never update. Did you mean to reference it inside either a function or a class?"

related discord posts
https://discord.com/channels/457912077277855764/1235970955612786719
https://discord.com/channels/457912077277855764/1278658234810634282
https://discord.com/channels/457912077277855764/1275188058089586688

Reproduction

.

Logs

No response

System Info

.

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions