[英]import variable in React native
i am storing values into three different variable.我将值存储到三个不同的变量中。
const companyValue = useSelector((state) => state.changeCompanyReducer.company);
const selectionValueArray = Object.values(companyValue);
const companyCode = selectionValueArray[0];
const employeeId = selectionValueArray[1];
i am getting 3 values from selectionValueArray , companyCode , employeeId .我从selectionValueArray 、 companyCode 、 employeeId获得 3 个值。
i want to place whole code in one file and import all these three variable name anywhere i want so that i can get 3 different values.我想将整个代码放在一个文件中,并将所有这三个变量名导入我想要的任何地方,这样我就可以获得 3 个不同的值。
How can i achieve this?Thanks.我怎样才能做到这一点?谢谢。
You can do something like this你可以做这样的事情
export const companyValue = your value
export const selectionValueArray = some value
Now you have to import like现在你必须像导入
import {companyValue, selectionValueArray} from './yourfile'
This type of import and export is called named export and import.这种类型的导入和导出称为命名导出和导入。
Learn more about it here 在此处了解更多信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.