我有两个文件。我想使用一个文件到另一个文件的变量。有没有一种方法可以实现这一目标。以下是一些文件,它们描述了我要实现的目标。谢谢。
index.js-要从中导入变量的文件
import React, { useState, useEffect, useMemo } from 'react';
import TableContainer from './base-table';
const TasksApp = () => {
//initial code to render data
const rowInfo = (rowobject) => {
// variable to be imported
const taskpath = `/${rowobject.cells[0].value}/runs`
history.push(taskpath)
}
//table returned
return(
<>
<TableContainer rowInfo={rowInfo} columns={columns} data={runs} />
</>
);
}
export default TasksApp;
basicRoutes.js文件显示基本路由,导入的变量就是其中之一。
export default {
home: "/",
login: "/login",
dashboard: "/dashboard",
// Nested Dashboard pages
table: '/dashboard/tasks',
runs: '/:value/runs', // instead of '/:value/runs', it should be the imported variable, taskpath
};