Skip to content

Instantly share code, notes, and snippets.

import initMixin from './internal/init'
import stateMixin from './internal/state'
import eventsMixin from './internal/events'
import lifecycleMixin from './internal/lifecycle'
import miscMixin from './internal/misc'
import dataAPI from './api/data'
import domAPI from './api/dom'
import eventsAPI from './api/events'
import lifecycleAPI from './api/lifecycle'
new Vue({
el: '#app',
data: {
message: 'Hello Vue.js!'
}
})
import initMixin from './internal/init'
/* ... */
function Vue (options) {
this._init(options)
}
/* ... */
@hectorlorenzo
hectorlorenzo / Main.md
Last active November 13, 2020 11:09
Learning React when coming from Vue

Learning React the Vue way

componentDidMount

Part of the component lifecycle, similar to created/mounted.

componentWillUnmount

Part of the component lifecycle, similar to destroyed

class CustomHeading extends HTMLElement {
constructor () {}
}
customElements.define('custom-heading', CustomHeading)
Vue.component('my-component', {
template: '<div>A custom component!</div>'
})
const customHeading = document.createElement('custom-heading')
document.body.appendChild(customHeading)
const elemClass = class extends HTMLElement {
constructor() {
super()
}
connectedCallback () {
const o = this
const data = o.options.data
Object.keys(data).forEach((key) => {
Object.defineProperty(o, key, {
const elemClass = class extends HTMLElement {
constructor() {
super()
}
attributeChangedCallback (name, oldValue, newValue) {
const o = this
const options = o.options
options.watch[name].call(o, oldValue, newValue)
}
const elemClass = class extends HTMLElement {
constructor() {
super()
}
static get observedAttributes () {
return Object.keys(this.options.data)
}
}