0.3.4 • Published 6 years ago
@ssr-coin/path-to-regexp v0.3.4
ssr-coin + path-to-regexp = :heart:
@ssr-coin/path-to-regexp
Routing with path-to-regexp.
(Note that @ssr-coin/path-to-regexp doesn't use the npm module path-to-regexp directly, but uses React Router's wrapper react-router/matchPath.)
Usage
Install @ssr-coin/path-to-regexp.
$ npm install @ssr-coin/path-to-regexpThe plugin is automatically loaded and
the route property of your page configs is now handled by path-to-regexp.
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>
);
}