Cannot Read Properties Of Null Reading Isadmin Useselector

[Solved] Cannot Read Properties Of Null Reading Isadmin Useselector | Actionscript - Code Explorer | yomemimo.com
Question : Cannot read properties of null (reading 'isAdmin') useSelector

Answered by : alien0w0

You should make your code safe.
For modern js you could use the optional chaining operator
const admin = useSelector((state) => state.user?.currentUser?.isAdmin)
A more traditional approach to do the same thing
const admin = useSelector((state) => state.user && state.user.currentUser && state.user.currentUser.isAdmin)

Source : | Last Update : Wed, 13 Jul 22

Answers related to cannot read properties of null reading isadmin useselector

Code Explorer Popular Question For Actionscript