I have a datatable in my react app and when I click on "Add New" button on the datatable, I open AddNew page (a reusable form). This page reads the form fields (employeeInputs
) given on the App.js
import { employeeInputs } from "./formSource";
function App() {
return (
<div>
<BrowserRouter>
<Routes>
<Route path="/">
<Route path="employees">
<Route
path="new"
element={<AddNew inputs={employeeInputs} title="Add New" />}
/>
</Route>
</Route>
</Routes>
</BrowserRouter>
</div>
);
}
export default App;
My question: If I use this approach, I can define new form fields for the other records e.g. Department, Salary ... and read fields in here by adding reference as:
import { employeeInputs } from "./formSource";
However, should I pass this parameter (name or the input, e.g. "employeeInputs") from the Datatable where I call this form? Otherwise, I do not make my App.js dirty with unnecesaary code. Any idea?