A very great feature in optional chaining.
Naturally, it is for objects. Check if this property exists or not.
But there is something that will benefit you.
It works with function as well
Like this
callback?.()
If this callback function exists? It will be implemented.
If it is not there. Nothing will happen
Here you will need it when you create a custom hook and pass a function to it as another parameter
and take a look at #rules_of_hooks
https://react.dev/reference/rules/rules-of-hooks
Naturally, it is for objects. Check if this property exists or not.
But there is something that will benefit you.
It works with function as well
Like this
callback?.()
If this callback function exists? It will be implemented.
If it is not there. Nothing will happen
Here you will need it when you create a custom hook and pass a function to it as another parameter
and take a look at #rules_of_hooks
https://react.dev/reference/rules/rules-of-hooks
🔥3❤1