daily pastebin goal
79%
SHARE
TWEET

Untitled

a guest Jan 19th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from 'react';
  2. import ReactDOM from 'react-dom';
  3. import ServerComponent, { server_component, consumer } from 'server_component';
  4.  
  5. @server_component('counter')
  6. class CounterContainer extends Component { }
  7.  
  8. @consumer('counter')
  9. class CounterBody extends Component {
  10.   render() {
  11.     const { increment, decrement, state: { count } } = this.props.counter;
  12.     return (
  13.       <div>
  14.         <h1>Counter</h1>
  15.         <button onClick={() => increment()}>increment</button>
  16.         <button onClick={() => decrement()}>decrement</button>
  17.         <hr />
  18.         <div>Count: {count}</div>
  19.       </div>
  20.     );
  21.   }
  22. }
  23.  
  24. class Main extends Component {
  25.   render() {
  26.     return (
  27.       <ServerComponent.Use at="/react" name="api">
  28.         <CounterContainer>
  29.           <CounterBody />
  30.         </CounterContainer>
  31.       </ServerComponent.Use>
  32.     );
  33.   }
  34. }
  35.  
  36. ReactDOM.render(<Main />, document.getElementById('root'));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top