Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. import React from 'react';
  2. import {
  3. Environment,
  4. IsomorphicApp,
  5. Route,
  6. WebApp,
  7. withIsomorphicState
  8. } from "infrastructure-components";
  9.  
  10. export default (
  11. <IsomorphicApp
  12. stackName = "isomorphic-state"
  13. buildPath = 'build'
  14. assetsPath = 'assets'
  15. region='eu-west-1'>
  16.  
  17. <Environment name="dev" />
  18.  
  19. <WebApp
  20. id="main"
  21. path="*"
  22. method="GET">
  23.  
  24. <Route
  25. path='/'
  26. name='Isomorphic-State'
  27. render={withIsomorphicState((props)=>{
  28. const [count, setCount] = props.useIsomorphicState("counter", 0);
  29.  
  30. // rerender 5 times ... but only at the server-side
  31. console.log("current count: ", count);
  32. if (count < 5) {
  33. setCount(count + 1);
  34. }
  35.  
  36.  
  37. return <div>
  38. <p>You clicked {count} times</p>
  39. <button onClick={() => setCount(count + 1)}>
  40. Click me
  41. </button>
  42. </div>
  43. })}
  44. />
  45. </WebApp>
  46. </IsomorphicApp>
  47. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement