Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
153 views
in Technique[技术] by (71.8m points)

javascript - Is it a good idea to create fields through a database

I'm a novice react developer working on a project, and was wondering if I could get some advice. This project is essentially converting a very complicated and large spreadsheet into a nice application. I'm also using material-ui for some of the components. The reason I'm here is because the way I currently have my fields set up feels wrong, and I was hoping some more experienced people could weigh in.

Essentially, I have all the data that creates each field in a psql database table (see the fieldData variable in the codesandbox) . I pull that data in via useEffect and axios, and run it through a function which outputs the fields (63 at the moment). I also have a reducer which controls the state of the components so I can add them together, and submit the data to the database, which I haven't implemented yet.

The reason I am running it through the database instead of just creating each component individually is so that later on, you can change/add fields from inside the application instead of having to edit the javascript. However, it feels like this is inefficient, or there's a better solution that I'm missing. I appreciate any help or feedback, thanks!

Codesandbox: https://codesandbox.io/s/adoring-dewdney-xx8w4?file=/src/App.js


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...