- Проверка фронтальной формы < /li>
Проверка формы на стороне сервера < /li>
Создание Database in Secuelize. Я думаю о том, чтобы динамически генерировать поля формы реагирования из объекта во время строительства вместо времени выполнения.
Причина - иметь единый источник истины, одно обновление обновляет все. Приложение ERP будет иметь сотни полей ввода без сложных операций или действий (CRUD). Я думал создать файлы JSX, как показано ниже во время Prebuild: < /p>
// UserSchema.json
const user = [
{ label: "Name", type: "text" },
{ label: "Email", type: "email" },
{ label: "Age", type: "number" }
];
< /code>
// CodeGenerator.js
// Of course this is a hardcoded example but it will be dynamically generate for all *Schema.json files.
const fs = require("fs");
const jsx = `
import React from "react";
export default function GeneratedFormItems() {
return (
${formItems.map(item => `
${item.label}
`).join("")}
);
}
`;
fs.writeFileSync("src/GeneratedFormItems.js", jsx);
< /code>
\\ package.json
"prebuild": "node CodeGenerator.js",
< /code>
My Question is:
Is this worth it or feasible. - What are the potential shortfall or challenges I may face with this approach.
- Has anyone ever tried something like this?
- Are there any libraries to help with this?
Подробнее здесь: https://stackoverflow.com/questions/797 ... tion-react