This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
| { | |
| "presets": ["es2015", "stage-1"], | |
| "plugins": [ | |
| "transform-h-jsx", | |
| "transform-decorators-legacy" | |
| ] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // having | |
| const myElement = <div class="foo"><b>My text</b></div>; | |
| // it renders to | |
| const myElement = h('div', { className: 'foo' }, [ | |
| h('b', ['My text']) | |
| ]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var h = require('virtual-dom/h'); | |
| var diff = require('virtual-dom/diff'); | |
| var patch = require('virtual-dom/patch'); | |
| var createElement = require('virtual-dom/create-element'); | |
| // 1: Create a function that declares what the DOM should look like | |
| const render = (count) => h('div', ['Count: ' + count]); | |
| // 2: Initialise the document | |
| var count = 0; // We need some app data. Here we just store a count. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { observable, autorun } from 'mobx'; | |
| const state = { @observable count: 0 }; | |
| autorun(() => console.log(state.count)); // => 0 | |
| state.count++; // => 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "scripts": { | |
| "dev": "webpack-dev-server --content-base build/", | |
| "..." | |
| }, | |
| "..." | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { diff, patch } from 'virtual-dom'; | |
| import { autorun } from 'mobx'; | |
| export default function mount(element, view, state) { | |
| let tree = <noop/>; | |
| function render() { | |
| const newTree = view(state); | |
| const patches = diff(tree, newTree); | |
| element = patch(element, patches); | |
| tree = newTree; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var webpack = require('webpack'); | |
| module.exports = { | |
| entry: [ | |
| './src/app', | |
| ], | |
| output: { | |
| path: 'build/', | |
| publicPath: '/', | |
| filename: 'bundle.js' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <html> | |
| <body> | |
| <div id="app"></div> | |
| <script src="/bundle.js"></script> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "presets": ["es2015", "stage-1"], | |
| "plugins": [ | |
| ["transform-h-jsx", { | |
| "pragma": "h" | |
| }], | |
| "transform-decorators-legacy" | |
| ] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { observable } from 'mobx'; | |
| const state = { @observable n = 0; } |
NewerOlder