让我们假设以下页面:
export default ({ SSRtasks }) => {
const [ tasks, setTasks ] = useState(SSRtasks)
const { data: freshTasks, mutate } = useSwr('/api/tasks')
useEffect(() => freshTasks && setTasks(freshTasks), [ freshTasks ])
return (
<ul>{tasks.map(task => <li>{task}</li>)}</ul>
)
}
export const getServerSideProps = async ({ req, res }) => {
const SSRtasks = Task.find({ owner: id })
return { props: { SSRtasks } }
}
知道任务在不断更新,对性能是否正确?
我找不到任何关于此的文档。(或者至少,理解)