I'm going through the code on a new project I'd like to contribute to, and the author has defined lots of methods using triple brackets, like this:
deinitialize() {{{
this.destroyed = true;
$(window).off("resize", this.resize as () => void);
if (this.resize_debounce) {
clearTimeout(this.resize_debounce);
this.resize_debounce = null;
}
this.svg.remove();
this.container = null;
}}}
I've never seen a triple bracket (brace? mustache?) used in that manner. My only experience with them has been in data binding with something like Polymer. What's going on here?
The project is written in typescript (which I also have no experience with), and this specific bit is in a .tsx file. It also uses React, which is probably irrelevant. Does this functionality come from one of those, or is it native JS that I've never seen?
The source code is here: https://github.com/online-go/online-go.com/blob/devel/src/components/RatingsChart/RatingsChart.tsx
Also, I apologize if this isn't clearly worded. I'm not really sure where these are coming from, and I'm not really familiar with the language or FWs used in this project. Thanks for your patience! (And editing, if required :))
In javascript statements you can use as many pairs of matching braces as you like:
function test(){{{
console.log("Im in lots of braces.");
}}}
test();
There is no change in behaviour whatsoever*. There is also nothing special in react that has any affect using this code.
My best guess is that the developer of the linked code follows some sort of convention for react components. But as far as I can tell it is not one used by the wider community, otherwise we would see this a lot more.
* Except perhaps a few extra nanoseconds to process it. H/T:Keith ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With