npm.io
0.3.4 • Published 7 years ago

@ssr-coin/react

Licence
—
Version
0.3.4
Deps
3
Size
3 kB
Vulns
0
Weekly
0
Stars
57

ssr-coin + React =

@ssr-coin/react

Use ssr-coin with React.

Usage

Install @ssr-coin/react.

$ npm install @ssr-coin/react

The plugin is automatically loaded and the view property of your page configs is now rendered with React.

Example

// /examples/basics/pages/welcome.page.js

import React, {useEffect, useState} from 'react';

export default {
  route: '/',
  view: () => (
    <div>
      Welcome to ssr-coin.
      <Time/>
    </div>
  ),
};

function Time() {
  const getTime = () => new Date().toLocaleTimeString();

  const [time, setTime] = useState(getTime());

  useEffect(() => {
    const timeout = setInterval(() => setTime(getTime()), 100);
    return () => clearTimeout(timeout);
  }, []);

  return (
    <div>
      The time is: <span>{time}</span>
    </div>
  );
}