Untitled

 avatar
unknown
javascript
5 months ago
501 B
21
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