Reputation: 75
Can I use the same name for the state and also the name of the function?
function BroadbandDeals() {
const [broadbandDeals, setbroadbandDeals] = useState([]);
return <div>Broadband Deals</div>;
}
Upvotes: 2
Views: 64
Reputation: 36227
Technically in your case yes as they have different casing but if the casing matched then no you wouldn't be able to have the same name.
Although I would say this is probably bad practice, as it can make debugging more difficult, as it's quite common for someone to ignore the case and just read the text not noticing you have two different things named the same with different cases.
Upvotes: 3