Debug: Print error on changing dependency array length between renders#2732
Debug: Print error on changing dependency array length between renders#2732marvinhagemeister wants to merge 2 commits into
Conversation
dfac5b2 to
8a49f07
Compare
|
Size Change: +563 B (1%) Total Size: 41 kB
ℹ️ View Unchanged
|
| function argsChanged(oldArgs, newArgs) { | ||
| return !oldArgs || oldArgs.length !== newArgs.length || newArgs.some((arg, index) => arg !== oldArgs[index]); | ||
| function argsChanged(oldArgs, newArgs, currentComponent) { | ||
| if (options._argsChanged) { |
There was a problem hiding this comment.
Does it make any difference if we extend the _hook option to handle this case? Perhaps something like getHookState(currentIndex++, 7, args) (we probably only need to pass args if the hook has an args param)
Looking at it now, should we invoke that _hook option after we have created/retrieved the hook state so we can pass it to the hook? Sounds like that would make the _hook option a lot more useful/powerful.
Will make the debug code more complex but if it saves bytes in product code, maybe that's worth it
There was a problem hiding this comment.
Just did that with the latest commit, but it turns out to be bigger than expected. It's 15B larger compared to the additional option hook. Another argument in favor of keeping options._hook as is, is that it's a breaking change, even though it's internals. Both devtools and prefresh are built on it.
f615e1e to
0f6da63
Compare
0f6da63 to
762e66b
Compare
762e66b to
3f26555
Compare
📊 Tachometer Benchmark ResultsSummaryA summary of the benchmark results will show here once they finish. ResultsThe full results of your benchmarks will show here once they finish. |
This PR adds a new error log to
preact/debugthat comes into play when the dependency array length of a hook changes between renders.Fixes #2728 .