The first destructuring creates only Start
and End
variables. If you want to create current
as a variable, then you need to declare it again.
function ({ current: { selectionStart: Start, selectionEnd: End }, current }, AppStateSetter) {
// do something with current , Start , and End
}
You can test it on the Babel compiler:
This code:
const object = {
current: {
selectionStart: "prop 1",
selectionEnd: "prop2"
}
}
const { current: { selectionStart: Start, selectionEnd: End } } = object;
Gets trasnpiled to:
var object = {
current: {
selectionStart: "prop 1",
selectionEnd: "prop2"
}
};
var _object$current = object.current,
Start = _object$current.selectionStart,
End = _object$current.selectionEnd;
As you can see, current
variable is not created.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…