안녕하세요 상훈입니다.

리액트를 다루는 기술이라는 책의 21강에서 사용되는 koa-router는 현재의 리액트 버전(17)에서는 사용할 수 없습니다.

설치방법

npm i koa-tree-router

 

사용 방법

const Koa = require("koa");
const Router = require("koa-tree-router");

const app = new Koa();
const router = new Router();
router.get("/", function(ctx) {
  ctx.body = "hello, world";
});

app.use(router.routes());

app.listen(8080);
// 혹은
app.listen(8000, () => {
  console.log('listening...8000...');
})

기존의 사용방식은 일치하고, 다른점은 하단의 app.use 부분입니다.

allowedMethods() 와 같은 긴 코드가 사라지고 위와같이 깔금한 내용만 남았습니다.

 

도움이 되셨다면 광고 한번 클릭해주세요. 블로그 운영에 큰 힘이 됩니다. 감사합니다.

 

 

 

koa-tree-router

A high performance koa router. Latest version: 0.10.1, last published: 11 days ago. Start using koa-tree-router in your project by running `npm i koa-tree-router`. There are 7 other projects in the npm registry using koa-tree-router.

www.npmjs.com

 

반응형

React.js 17 버전은 다르게 다운로드 받아야합니다.

에러 내용

npm ERR! Could not resolve dependency:
npm ERR! peer react@"^15.3.0 || ^16.0.0-alpha" from react-virtualized@9.22.3
npm ERR! node_modules/react-virtualized
npm ERR!   react-virtualized@"9.22.3" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

 

버전이 안맞기 때문에 아래와 같은 명령어로 다운받아주세요

 npm install react-virtualized --legacy-peer-deps

 

설치가 잘되었고 퍼포먼스가 훌륭해진것을 확인하실 수 있습니다.

 

기존의 작업 시간보다 훨씬 줄었더군요.

물론 pc스펙에 따라 달라질 수 있습니다.

 

도움이 되셨다면 광고 한번 클릭해주세요. 블로그 운영에 큰 힘이 됩니다. 감사합니다.

 

 

Support React 17 · Issue #1616 · bvaughn/react-virtualized

Currently, react-virtualized has a peer dependency on react and react-dom that constraints it to React 16. From my experiments, it already seems to work with React 17 so this might be as simple as ...

github.com

 

react-virtualized

React components for efficiently rendering large, scrollable lists and tabular data. Latest version: 9.22.3, last published: a year ago. Start using react-virtualized in your project by running `npm i react-virtualized`. There are 1399 other projects in th

www.npmjs.com

 

반응형

+ Recent posts