I have this hook and I need export a const with an boolean value, this way is sending a string.
export const useType = () => {
const isFoo = 'string';
const isBar = 'other_string';
return { isFoo, isBar };
};
How can I transform this in an boolean value?
I'm new, Thanks if anyone can help me
CodePudding user response:
I am not sure if I understand your question correctly but you mean this?
export const useType = () => {
const isFoo = 'string';
const isBar = 'other_string';
const iAmBoolean = true;
return { isFoo, isBar, iAmBoolean };
};
CodePudding user response:
Assuming that you need to check if a value is an string equivelent to isFoo and isBar.
export const useType = (props) => {
if(props === 'isFoo'){
return true
}else{
return false
}
}
//then you call useType(varWithTheString) to check if it's Foo or not.