BuilderIO / BuilderIO/mitosis

onUpdate first argument should be deps not second

Open
#409 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
14.4k
Forks
671
PR merge metrics
No merged PRs in 30d

Description

the first arg should be the deps. We shouldn't follow react pattern for this since react was overloading useEffect for multiple usage (with dep array with no args, vs dep array with args, vs no dep array)

```jsx
onUpdate([prop.hi, state.bye], () => {
context.someSideEffectFetch()
.then((newValue) => {
state.anotherValue = newValue;
});
});
```

@steve8708 what do you think?

this will be a breaking change so we should support both in the jsx parser but change the docs

Contributor guide

Open the contributing guide

Research direction

Locate the JSX parser and the documentation for onUpdate. First trace how the current argument order is parsed, then check the existing docs and tests if available. Done means both argument orders remain supported by the parser while the documentation presents dependencies as the first argument.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
compilers, documentation
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.