score:1

Accepted answer

you need to move the hook out of the event handler, and in to the body of the component.

import react, { usestate } from 'react';
import usefetchngsdata from '../usefetchngsdata';

const data = (props) => {
    const { data: players } = usefetchngsdata('/league/roster/current?teamid=5100')
    return (
        <div>
            // ... handlegetplayers
        </div>
    );
}

export default data;

but really, you don't need to use setplayers here. you already have that data in your returned values from your custom hook.


Related Query

More Query from same tag