zthxxx / react-dev-inspector

jump to local IDE code directly from browser React component by just a simple click
https://react-dev-inspector.zthxxx.me
MIT License
1.15k stars 68 forks source link

An example about use in some frameworks like blitz.js #121

Closed zongzheng123 closed 1 year ago

zongzheng123 commented 2 years ago

Thanks for review. In some frameworks like blitz.js,there are a intermediate state for compilation, so the process.cwd() in middleware function "launchEditorMiddleware" will get the error base workplace, so perhaps can provide some options for user customizing their config. Of course, you can have a trick like this

const fixLaunchEditorMiddleware = (req, res, next) => { const cwd = process.cwd process.cwd = () => path.resolve(cwd(), "../../") launchEditorMiddleware(req, res, next) process.cwd = cwd }

zthxxx commented 2 years ago

@zongzheng123 may see docs of #inspector-component-props

your code could like

<Inspector
  disableLaunchEditor={true}
  onClickElement={(params: InspectParams) => customLocateBlitz(params)}
>
zongzheng123 commented 2 years ago

what you mean is change context by mutating InspectParams, right?

zthxxx commented 2 years ago

via get relativePath of file,you can do anything yourself

zthxxx commented 1 year ago

It's add in dev branch as beta, and you can access it by: https://stackblitz.com/github/zthxxx/react-dev-inspector/tree/dev/?file=examples/vite4/package.json