[英]How to use existing javascript codes in react components
I am new to React Js. 我是React Js的新手。 I have some normal javascript codes for frequently used calculations and etc and it has lots of javascript codes.
我有一些常用的javascript代码用于经常使用的计算等,并且它有很多javascript代码。
Now i am moving to React Components and like to use same codes which i have written in plain javascript in my react components instead of re-writing everything. 现在我要转向React组件,并且喜欢使用我在React组件中用纯JavaScript编写的相同代码,而不是重新编写所有内容。
Kindly help me on this. 请帮助我。
Think of creating a util/ or lib/ folder on the root of your project. 考虑在项目的根目录上创建util /或lib /文件夹。 You can export those functions etc and use anywhere as you would normally.
您可以导出这些功能等,然后像往常一样在任何地方使用。
There is nothing related to react, except you shoudn t try to update the dom via plain JS. 与反应无关,除了您不应尝试通过纯JS更新dom。 Shortly, let react do what it does, elsewhere use your own util, lib helpers without issues.
很快,让react做它所做的事情,在其他地方使用您自己的util,lib帮助程序而不会出现问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.