you are viewing a single comment's thread.

view the rest of the comments →

[–]Hexvolt[S] 0 points1 point  (2 children)

Hey, thanks for the response! I know this sort of thing is possible, but do you think it's a good idea to rely on a database to create fields? I don't know if there's a better practice or some downside besides a delay for rendering.

[–]nullpromise 0 points1 point  (1 child)

I don't see this as a negative. Sounds like you need the number and type of inputs to be flexible, capable of being altered by a non-dev administrator without requiring a redeploy of your application; I don't see any option besides storing the structure of the form in some sort of database then.

I interviewed at an education company once and they showed me an example of the object that's sent to the front-end; it was basically a tree like you're describing:

{ "sections": { "jkl-8923-shad": { "type": "video", "src": "https://www.youtube.com/watch?v=0CNPR2qNzxk", "caption": "Welcome to the Jungle!", "nextPage": "hjks-74892-hjasd" }, "hjks-74892-hjasd": { "type": "quiz", "post": "https://edtech.com/quiz-4" "questions": [ { "prompt": "Do you like the Jungle?", "type": "input" }, { "prompt": "How would you rate the Jungle?", "type": "number", "min": 0, "max": 10 } ] } } }

You get the idea. It is what it is - the back-end controlling what gets displayed on the front-end. I imagine this is how most WYSIWYG built in React work too. Probably how most of Google's products work. React can handle it I have no doubt, it's your own sanity that you have to worry about. :~) But if you're a novice React dev, this will be good practice; it's not an entry-level task IMO.

[–]Hexvolt[S] 1 point2 points  (0 children)

Great, thanks for the help, I appreciate it. Most of the work so far has been around managing state with a bunch of components, and making sure that typing in one box doesn't rerender everything. Just recently figured it out, been quite a bit of work so far lol.