Cache callback functions

This commit is contained in:
Vladimir Borisov 2019-09-30 15:18:11 +03:00
parent 15d325e571
commit 6c07ebe992
No known key found for this signature in database
GPG key ID: F9A584BE4FCB6603

View file

@ -13,18 +13,18 @@ const SectionsList = React.forwardRef(({ className, sections, preferences, onPre
onPreferenceChanged(id, color);
};
const updateDropdown = (event) => {
const updateDropdown = React.useCallback((event) => {
var data = event.currentTarget.dataset;
onPreferenceChanged(data.name, data.value);
};
});
const checkUser = (event) => {
const checkUser = React.useCallback((event) => {
if(! preferences.user) {
// Here in Stremio 4 we show a toast with a message, asking the anonymous user to log in/register
console.log('No user found');
event.preventDefault();
}
}
});
// Determines whether the link should be opened in new window or in the current one.
const getTargetFor = url => ['//', 'http://', 'https://', 'file://', 'ftp://', 'mailto:', 'magnet:']