mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
fix(transformer/react): react refresh panics when encounter use hook (#5768)
close: #5766 I even forgot that React has a `use` hook in the latest version
This commit is contained in:
parent
e8bf30a125
commit
3cc38dfc05
3 changed files with 4 additions and 2 deletions
|
|
@ -930,7 +930,7 @@ fn is_componentish_name(name: &str) -> bool {
|
|||
}
|
||||
|
||||
fn is_use_hook_name(name: &str) -> bool {
|
||||
name.starts_with("use") && name.chars().nth(3).unwrap().is_ascii_uppercase()
|
||||
name.starts_with("use") && name.as_bytes().get(3).map_or(true, u8::is_ascii_uppercase)
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
|
|
|
|||
|
|
@ -10,5 +10,6 @@ export default function App() {
|
|||
const baz = FancyHook.useThing();
|
||||
React.useState();
|
||||
useThePlatform();
|
||||
use();
|
||||
return <h1>{bar}{baz}</h1>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,9 +15,10 @@ export default function App() {
|
|||
const baz = FancyHook.useThing();
|
||||
React.useState();
|
||||
useThePlatform();
|
||||
use();
|
||||
return _jsxs("h1", { children: [bar, baz] });
|
||||
}
|
||||
_s2(App, "useFancyState{bar}\\nuseThing{baz}\\nuseState{}\\nuseThePlatform{}", true, function() {
|
||||
_s2(App, "useFancyState{bar}\\nuseThing{baz}\\nuseState{}\\nuseThePlatform{}\\nuse{}", true, function() {
|
||||
return [FancyHook.useThing];
|
||||
});
|
||||
_c = App;
|
||||
|
|
|
|||
Loading…
Reference in a new issue