How to fix Cannot infer generic type parameter, specify type explicitly in React | DevErrors