I have 2 functions called isTrue and isFalse.
export function isTrue(param) {
return param === true;
};
export function isFalse(param) {
return param === false;
};
I have a few buttons in react native which change from disabled state want a variable is true or false. I could do it like this:
<Button
text="This is a button"
onPress={handlePress}
isDisabled={var === true}
/>
But now I'm using the functions like this:
<Button
text="This is a button"
onPress={handlePress}
isDisabled={isTrue(var)}
/>
When adding a console.log to the 'isTrue'-function, I see it gets called a lot (every re-render).
Is this bad for performance. I'm not seeing any performance issues, but it's quiet a simple app (for now) and I don't think the calculations in this function is't difficult.
I'm planning to add more functions like isNull, isNotNull. It's just for myself, var === null works like isNull(var) but for me it's easier to read. If there could be any performance issues, I switch back again.