I'm typically a back-end programmer so to assist with some of the initial work i got a project that had a template project set up. I'm trying to understand some things as my first React Native Project and i can't seem to understand what this logic is saying for bgColor? :
const navbarStyles = [
styles.navbar,
bgColor && { backgroundColor: bgColor }
];
Any explanations or references that could help? Appreciate it!
It's called short-circuiting and is a short-hand way of doing:
if (bgColor) { //implies bgColor != undefined (and also != null, != 0 etc)
backgroundColor: bgColor
}