dillon1000/react
Commit
Browse files Dont count throw as an exit node (React semantics)
React will retry or abort components that throw (depending on a few conditions),
so from React's perspective a `throw` statement is not a normal exit node. Thus
the Rules of Hooks really have a caveat: the set of hooks that are called _in an
execution that returns successfully_ must be consistent. Examples such as the
following are therefore allowed:
```javascript
function Component(props) {
if (props.cond) {
throw new Error(...);
}
useHook();
}
```
By modeling `throw` as an exit node, we rejected cases such as this. This diff
changes to not model throws as exit nodes. #1584 changes this to make it an
option, since some cases will want to consider throw as an exit node.Changed paths1 file
First-parent comparisoncompiler/forget/src/HIR/Dominator.ts ModifiedPatch
Files changed
Rendering syntax-highlighted changes…