Reputation: 4859
I am new with react native and I am trying catching an error in this way
Linking.openURL('test').catch(err =>
alert('error' + err)
);
But If I try to log the error like this
Linking.openURL('test').catch(err =>
alert('error' + err); // error in this line
console.log(err);
);
I get a syntax error because of the comma.
Upvotes: 0
Views: 1695
Reputation: 5025
You're just missing the braces in the arrow function.
Linking.openURL('test').catch(err => {
alert('error' + err); // error in this line
console.log(err);
});
You need braces if your arrow function has more than one sentence.
If you don't have braces, you should only have one sentence whose result will be automatically returned.
Upvotes: 2