4 ms·
Not sure I understand your 3rd pattern, what does const {LoginForm} = this; do?
by floriferous 10y ago
Not sure I understand your 3rd pattern, what does
const {LoginForm} = this; do?
- hokkos 10y agoIt destructures this, to get the LoginForm property, it could be written <this.LoginForm> because even if it starts with a lower case character that are transformed as string when there is a dot it is transformed as object : <component /> compiles to React.createElement('component') (html tag) <Component /> compiles to React.createElement(Component) <obj.component /> compiles to React.createElement(obj.component)
- deleted 10y ago[deleted]
- tmnvix 10y agoIt is basically equivalent to `LoginForm = this.LoginForm`. It is called destructuring and is one of the nice conveniences of es6 javascript. Importantly you can also do this: var o = {p: 42, q: true}; var {p, q} = o; console.log(p); // 42 console.log(q); // true