Refering local valiable without `this` in function component

I want to refer to the variable in function component,
I think normally I use this to refer to local variable.

However in function component,I can’t use this.

Maybe, I am still confused by function component though…

export default function TrackPage(props) {
    const classes = useStyles();

    useEffect(() => {
       var playlist = 1;
    }
    function handleToolBarClick(){
        this.playlist // this is empty.
    }
}

45 thoughts on “Refering local valiable without `this` in function component”

Leave a Comment