I've seen these pattern in a CodeReview question:
toggleModal({title = null, description = null, cancelLabel = 'No', submitLabel = 'Yes'} = {}) {
this.setState({
modalVisible: !this.state.modalVisible,
title: title,
description: description,
cancelLabel: cancelLabel,
submitLabel: submitLabel
});
},
The complete post: http://ift.tt/2dczfHO
I would say it's a combination of ES6 Default Parameter with Destructuring.
Have tried to understand the purpose. But still not idea.
Why aren't Default Parameter used alone?
Can anyone explain me what this pattern is about?
Aucun commentaire:
Enregistrer un commentaire