I want a quick check like assert(route?.params?.array !== undefined)
.
The closest I've found is node's assert
library. But I don't think that's useable out of the box with React-native. (If it is, I'd accept an answer showing me how!)
I would accept a try catch
code where I can catch if array is undefined.
Right now I'm doing something like
try {
route.params.array.length;
} catch(err) {
console.log("ERR: looks like array is undefined.");
}
But I would like something less hacky. Also, any suggestions about how to do testing properly in React-Native are welcome.
Aucun commentaire:
Enregistrer un commentaire