Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何调试开源项目---react-router #63

Open
xiaochengzi6 opened this issue Nov 10, 2022 · 0 comments
Open

如何调试开源项目---react-router #63

xiaochengzi6 opened this issue Nov 10, 2022 · 0 comments

Comments

@xiaochengzi6
Copy link
Owner

在开始调试开源项目之前应该先去简单的了解 其仓库所在源码位置,清楚的知道源码之间文件在那些地方跳转

然后就可以从入口处开始看了,应该配合着相关博客一起看,当然 如果深入到源码中,里面定义了非常多的相关变量,到最后理解起来非常困难

这个时候就可以去调试源码了,在你看不懂相关代码的地方,应该是某个功能处,你可以去做一个相关的例子,但是这里的 react-router 直接给出了,由于 useRoutes 是核心API 且也是最难理解的部分 所以因该从这里开始,可以在 开源仓库中 examples/routes-objects项目中,这是官方直接给出的例子,配置好 launch.json就可以调试了,

这里需要下载好相关依赖,然后启动项目,配置好 launch.json

{
  "version": "0.2.0",
  "configurations": [

    {
      "name": "Launch Chrome",
      "request": "launch",
      "type": "chrome",
       // 这里的 url 就是你启动项目的地址
      "url": "http://localhost:3000",
      "webRoot": "${workspaceFolder}"
    },
  ]
}

现在就可以调试代码了,调试的过程中不可以对源码进行修改,需要在目前位置打一个断点然后停止调试,去写好注释,然后下一次在调试跳转进来,使用 第三方库可以去保存我们对 node_modules 下做出的修改

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant