View ServerOnly.js
import React from "react" | |
import {findDOMNode} from "react-dom" | |
export default React.createClass({ | |
componentWillMount() { | |
if (process.browser) { | |
this.setState({html: findDOMNode(this).innerHTML}) | |
} | |
}, | |
render() { |
View ClientOnly.js
/* | |
* <ClientOnly> | |
* <MyStuff /> | |
* </ClientOnly> | |
*/ | |
export default React.createClass({ | |
getInitialState() { | |
return { allowRender: false } | |
}, | |
componentDidMount() { |
View clientti.js
const initial = JSON.parse(app.getAttribute('data-state')) | |
console.log(initial) |
View clientti.js
const he = require("he") | |
const initial = JSON.parse(he.unescape(window.INITIAL_STATE)) | |
console.log(initial) | |
View clientti.js
// bundlen entry point | |
const he = require("he") | |
const initial = JSON.parse(he.unescape(document.getElementById("state").innerHTML)) | |
console.log(initial) |
View index.js
// require() some stuff from npm (like you were using browserify) | |
// and then hit Run Code to run it on the right |
View app.js
import React from "react" | |
import {render} from "react-dom" | |
import Bacon from "baconjs" | |
import {sum} from "lodash" | |
import {atom} from "megablob" | |
import {Combinator} from "megablob/react" | |
function init() { |
View app.js
import React from "react" | |
import Bacon from "baconjs" | |
import {render} from "react-dom" | |
import {range, sum} from "lodash" | |
import combineAsComponent from "./combineAsComponent" | |
import Atom from "./atom" |
View counterz.js
import React from "react" | |
import Bacon from "baconjs" | |
import {render} from "react-dom" | |
function Counter(initial) { | |
const incBus = new Bacon.Bus() | |
const value = incBus.map(1).scan(initial, (state, inc) => state + inc) | |
value.inc = () => incBus.push() | |
return value | |
} |
View app.js
import React from "react" | |
import Bacon from "baconjs" | |
import {render} from "react-dom" | |
import liftVDOM from "./liftVDOM" | |
import combineAsComponent from "./combineAsComponent" | |
import Atom from "./atom" | |
function initApp() => { |