Reputation: 131
On one of my PRs, my colleague comment to use return before these functions call is it a good practice to use return in onClick.
Note: these functions do not return anything.
onClick={() => {
if (isPlatform) {
handlePlatformChange({ selectedPlatform: item, selectedTab: index });
} else if (isExecution) {
handleExecutionMode(item);
} else {
handleBrowserChange([item], index);
}
}}
Upvotes: 1
Views: 25
Reputation: 1159
I don't believe there is any problem with returning in onClick
.
I do agree that it would be more convenient to read if you would return.
For example :
onClick={() => {
if (isPlatform) {
return handlePlatformChange({ selectedPlatform: item, selectedTab: index });
}
if (isExecution) return handleExecutionMode(item);
return handleBrowserChange([item], index);
}
}
Upvotes: 2