Skip to content

Instantly share code, notes, and snippets.

View koba04's full-sized avatar

Toru Kobayashi koba04

View GitHub Profile
import React from 'react';
import ReactDOMServer from 'react-dom/server';
import express from 'express';
import Html from './Html';
import App from './App';
const app = express();
app.use('/static', express.static('public'));
import React from 'react';
const Html = (props) => {
return (
<html>
<head>
<title>App</title>
</head>
<body>
<div id="app">{props.children}</div>
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
const initialData = JSON.parse(document.getElementById('initial-data').getAttribute('data-json'));
ReactDOM.render(<App {...initialData} />, document.getElementById('app'));
import React from 'react';
import ReactDOMServer from 'react-dom/server';
import express from 'express';
import Html from './Html';
import App from './App';
const app = express();
app.use('/static', express.static('public'));
import React from 'react';
const Html = (props) => {
return (
<html>
<head>
<title>App</title>
</head>
<body>
<div id="app" dangerouslySetInnerHTML={ {__html: props.markup} }></div>
import React from 'react';
const App = (props) => {
return <div>Hello {props.name}</div>;
};
export default App;
import React from 'react';
import TestRenderer from 'react-test-renderer';
class MyComponent extends React.Component {
constructor(props) {
super(props);
this.input = null;
}
componentDidMount() {
this.input.focus();
import React from 'react';
import TestRenderer from 'react-test-renderer';
const Child = props => <div>{props.children}</div>;
const Counter = props => <div>{props.count}</div>;
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
import React from 'react';
import TestRenderer from 'react-test-renderer';
const Text = (props) => <p>{props.children}</p>;
const App = () => (
<section>
<h1>Hello</h1>
<Text>hogehoge</Text>
</section>
@koba04
koba04 / test.js
Last active September 11, 2017 09:12
A React TestRenderer Sample
const React = require('react');
const TestRenderer = require('react-test-renderer');
const Child = props => <div>{props.children}</div>;
const Counter = props => <div>{props.count}</div>;
class App extends React.Component {
constructor(props) {
super(props);
this.state = {