-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Describe the need
It seems to be allowed to access props
inside an onSomething
function, e.g.
const onSomething = (): void => {
const duration = props.duration;
console.log(duration);
}
However using a factory/currying pattern causes reactivity issues:
// Warning: "This function should be passed to a tracked scope..."
const onSomething = (delay: number): void => () => {
const duration = delay + props.duration;
console.log(duration);
}
Even when attempting to name the inner function onSomething
(not great anyway)
// Warning: "This function should be passed to a tracked scope..."
const createSomethingHandler = (delay: number): void =>
function onSomething(): void {
const duration = delay + props.duration;
console.log(duration);
}
}
Suggested Solution
Recognize the pattern :)
Possible Alternatives
Sometimes it is possible to pass all the props at the creation point (which would happen safely in an effect/JSX), but it isn't always practical.
Additional context
- I would be willing to contribute a PR to implement this feature
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request