I want to refer to the variable in the function component,
I think normally I use this to refer to the local variable.
However, in the function component, I can't use this.
Maybe, I am still confused by the function component though...
export default function TrackPage(props) {
const classes = useStyles();
useEffect(() => {
var playlist = 1;
}
function handleToolBarClick(){
this.playlist // this is empty.
}
}
useState(if changing it should cause a re-render), or in a ref withuseRef(if you want to change the value without triggering a re-render).this, Function components are stateless, or use hooks as Jayce mentions above, which essentially enable state to persist across render and be accessed viauseState, etc.