mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[lint] treat React.use() the same as use() (#27769)
We should probably treat `React.use()` the same as `use()` to allow it within loops and conditionals. Ideally this would implement a test that `React` is imported or required from `'react'`, but we don't otherwise implement such a test.
This commit is contained in:
@@ -489,9 +489,12 @@ const tests = {
|
||||
},
|
||||
{
|
||||
code: normalizeIndent`
|
||||
import * as React from 'react';
|
||||
function App() {
|
||||
if (shouldShowText) {
|
||||
const text = use(query);
|
||||
const data = React.use(thing);
|
||||
const data2 = react.use(thing2);
|
||||
return <Text text={text} />
|
||||
}
|
||||
return <Text text={shouldFetchBackupText ? use(backupQuery) : "Nothing to see here"} />
|
||||
|
||||
@@ -108,7 +108,7 @@ function isUseEffectEventIdentifier(node) {
|
||||
}
|
||||
|
||||
function isUseIdentifier(node) {
|
||||
return node.type === 'Identifier' && node.name === 'use';
|
||||
return isReactFunction(node, 'use');
|
||||
}
|
||||
|
||||
export default {
|
||||
|
||||
Reference in New Issue
Block a user