I've had a bit longer to think about the shouldRenderForBrowser function and below are some suggestions:
Defer determining the current browser until it is required (i.e. if the all or none props are provided the current browser is irrelevant).
It is not necessary to maintain two lists (restricted and allowed) because by definition any browser which is restricted cannot be allowed and vice versa.
The number of return statements can be reduced as false is the default.
I ported this code from an old project which was built in a hurry. As I ported, I failed to look into optimization points thinking it should already be optimized. This is what happens when you trust your code blindly.
Thanks for all these pointers. I'm gonna refactor the component again and loop in all these suggestions. You are amazing!
I've had a bit longer to think about the shouldRenderForBrowser function and below are some suggestions:
all
ornone
props are provided the current browser is irrelevant).This leads to something like this:
This is brilliant.
I ported this code from an old project which was built in a hurry. As I ported, I failed to look into optimization points thinking it should already be optimized. This is what happens when you trust your code blindly.
Thanks for all these pointers. I'm gonna refactor the component again and loop in all these suggestions. You are amazing!
Also, if you're interested in creating a PR, feel free to play around.