redux - VS code - search for function reference within specific function- macOS
问题描述
is there any quick way in vs code to search for method1 referenced inside method2?
I am trying to see if using remote-redux-devtools is useful for my project, and we are using next js which does server side calls via getInitialProps
so I am trying to find all references to dispatch
inside getInitialProps
rather than search for either term (dispatch
or getInitialProps
) via command + shift + F
individually, i need a more specific search.
in this case I need to search for references to dispatch
inside getInitialProps
解决方案
如果我们可以假设您的getInitialProps
函数的形式类似于:
static async getInitialProps(ctx) {
const res = await fetch('https://api.github.com/repos/zeit/next.js')
const json = await res.json()
dispatchEvent(event)
return { stars: json.stargazers_count }
}
特别是关于return
最后一行的语句,那么这个正则表达式可以将这些getInitialProps
函数与该函数中dispatch
某处的序列区分开来。
^.*getInitialProps[\s\S]*?\bdispatch[\s\S]*?(return).*\n.*
如果你只想要dispatch
而不是dispatchEvent
你可以在它周围使用单词边界,\bdispatch\b
除非它被用作dispatch(
然后使用\bdispatch(
或类似的。
推荐阅读
- java - (hello-> h3o) 如何在字符串中替换中间字母为替换的字母数
- google-apps-script - 如何在 GAS 中创建一个脚本,以在 Google 表格中创建一个按钮或其等效项?
- graphql - Can't custom value of graphql enum
- python - 对数据框中的前 N 行起作用?
- bash - git clone 后 git 差异无法正常工作
- flutter - Flutter ml 套件不工作,可能在 Catalina 更新之后
- javascript - 组件 CommentListComponent 不是任何 NgModule 的一部分,或者该模块尚未导入您的模块
- java - 在 Android 中使用 Retrofit 2 解析两个不同的 API 响应
- keycloak - keycloak 网守中重定向 url 的目的是什么?
- mysql - Django 查询集更新迁移