EduardS – 18-34 Feb 8
How to solve calling hooks conditionally here?
I have this
data
coming from validateData
that returns some data if valid otherwise null
. I then check if data
exists and return early otherwise. After that I use useCustomHook
that depends on that data
but because I returned early I get a warning that hook is called conditionally. How can I avoid this issue?
E
EduardS•446d ago
In return jsx should be someOtherData but yeah its just an example hope its clear enough
UU
Unknown User•446d ago
E
EduardS•446d ago
@alexanderlill I asked the question in react-forum as well and that answer helped me.
https://discord.com/channels/102860784329052160/1072888209383637073
Thanks for the other links they have been very informative!
@iang unfortunately I cant modify the useCustomHook so the best solution was to wrap it in another component like someone suggested in my other post https://discord.com/channels/102860784329052160/1072888209383637073
UU
Unknown User•445d ago
230KMembers
View on DiscordMore Posts
How to avoid calling hook conditionally here?I have this `data` coming from `validateData` that return the `rawData` if valid otherwise `null`. Endo – 07-14 Feb 8Does anyone know how to autoplay video with sound? I know there is a Autoplay policy. but for exampkairu – 14-23 Feb 7I have a section in my code I don't really understand.
`function nameOfFunction(a, b = null, c = ✅ – HalcyonXII – 12-44 Feb 4why this returns empty⛄Snowberb⛄ – 11-53 Feb 2What is it called the date that we use to calculate the time on JS? This description sucks but it wa