Untitled
Anonymous
javascript
10/23/2024 7:30 AM
668 B
30
Indexable
// something.js
// this should be a hook but isn't
// but this is allowed because of the upper case letter
function FetchSomething() UseQueryResult<Somehting> {
return useQuery(...)
}
export { FetchSomething as fetchSomething }
// component.js
function MyComponent: React.FC<> {
return (
<SomeOtherComponent
callback={() => fetchSomething()} // hooks are not allowed here but it works becasue the compiler does not recognise the function to be a hook
/>
);
}Editor is loading...
Leave a Comment