87b96d3dcac839bb14439abd5638d7bb40d7a815
Gitcub / pages / index.js
import { useRouter } from 'next/router'
import React, { useState, useEffect } from 'react'

const Main = () => {
  
  const router = useRouter();
  
  const [items, setItems] = useState([]);

  useEffect(() => {
    if (!router.isReady) return;
    
    setItems(() => router.query.text.split('/'));
  }, [router.isReady])
  
  return (
    <ul>
      {items.map(item => (
        <li>{item}</li>
      ))}
    </ul>
  )
}

export default Main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25