0

As a programmer, I love shortcuts, and I'm very curious. So I was wondering, is there any way to do this shorter ?

const {params} = props.route;
const transactionId =
  params && params.transactionId ? params.transactionId : null;

Basically, I am looking for a way to access props.route.params.transactionId if and only if props.route.params is defined, so I can get the (potential) value of transactionId without raising an exception if props.route.params is undefined.

Alarid
  • 770
  • 1
  • 6
  • 19

0 Answers0