admin管理员组文章数量:1431717
I have some ponent like this
const Component = ({ oldPropName }) => ...
which I want to refactor to:
const Component = ({ newPropName }) => ...
and I want all occurrences of this oldPropName
across all files to be changed automatically. Is there way to do this with VSCode?
Essentially same question can be asked as how to rename a destructured function parameter across the files without thinking about React ponents.
I have some ponent like this
const Component = ({ oldPropName }) => ...
which I want to refactor to:
const Component = ({ newPropName }) => ...
and I want all occurrences of this oldPropName
across all files to be changed automatically. Is there way to do this with VSCode?
Essentially same question can be asked as how to rename a destructured function parameter across the files without thinking about React ponents.
Share Improve this question asked Nov 7, 2021 at 16:26 wunnlewunnle 791 silver badge5 bronze badges 6- Why does search-and-replace not work for you here? – jmargolisvt Commented Nov 7, 2021 at 16:30
- Does this answer your question? How do I find and replace all occurrences (in all files) in Visual Studio Code? – Randy Casburn Commented Nov 7, 2021 at 16:32
-
@jmargolisvt It doesn not because
oldPropName
may be a mon prop name likeonClick
. Search and replace will accidentally change prop names of irrelevant ponents. – wunnle Commented Nov 7, 2021 at 16:37 - @RandyCasburn Unfortunately not. See the ment above – wunnle Commented Nov 7, 2021 at 16:38
- According to your question, though, there are no irrelevant ponents. You want to make this change across all ponents. – Andy Commented Nov 7, 2021 at 17:08
2 Answers
Reset to default 2F2 will change all variable occurrences in the code if you disable the following settings:
You can right click the oldPropName
and there should be a "Rename Symbol" option or you can use F2. Some languages support rename symbol across files. Press F2 and then type the new desired name and press Enter. All usages of the symbol will be renamed, across files.
本文标签: javascriptHow to rename a React component prop across all filesStack Overflow
版权声明:本文标题:javascript - How to rename a React component prop across all files? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745552192a2662993.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论