7
7
700Hp2021-12-26 19:16:07
JavaScript
700Hp, 2021-12-26 19:16:07

vue, react. Is it worth decomposing form elements if there are a lot of them?

In development, I encountered a large abundance of inputs.
I don't use the global state. (not my whim)
All inputs of UI elements - (error handling is already provided, so it's enough to throw props)
Split the form into several stages. Faced with the issue of implementation.
1. Leave it as it is, put the inputs in a div, and depending on the stage of the form, show certain fields.
I tend to this option, it is convenient to validate, there is no repetition, but the component is cumbersome.
2. Crush into several forms. From one to transfer data to another and in the final already send a request to the server. Each form validates the data and sends the component to the trace only if the validation is successful.

We are talking about 20 inputs.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Aetae, 2021-12-26
@700Hp

Well, if the fields should be on the same screen, then 1., if at several steps, then 2.
If you choose exactly what between the options, then why are you doing the work of the designer?)
In general, it doesn’t matter.
PS If it turns out cumbersome - something is wrong with your input elements. If you have to prescribe the same thing for them - make a wrapper that uses the context\provide, there should be no repetitions in the code.

K
Kirill, 2015-08-25
@kirill89

You should work in a team, you will immediately understand why all this is needed. In general, learn laravel, yii or any other framework, use it in your work through "I don't want to". After a couple of weeks, you will wonder how you managed without it. Read security questions, LFI, SQL injection. You will probably learn a lot about your projects and, again, understand why to use a framework. Read Clean Code, Design Patterns, and a dozen other well-reviewed books. Go to interviews, even without the goal of getting a job, you will immediately understand what exactly you are missing in knowing your tools.

R
Ramil, 2015-08-25
@rshaibakov

If you have chosen the PHP programming language, then the first thing you need to study, in my opinion, is the material on the site http://getjump.me/ru-php-the-right-way/ . These are the fundamentals of PHP programming.
I also recommend reading the book "PHP. Objects, Templates and Programming Techniques". Author - Matt Zandstra.
And the main thing is constant practice. Code every day and don't be afraid to experiment.

E
Eugene, 2015-08-25
@nimfai

Take some lighter framework, for example, I took CodeIgniter (I don’t know what could be easier than it), and start reading the documentation (google it, there is a translated one, just make sure that the versions of the framework and the engine match). In MVC, it is important to understand the principle, and then, with practice, everything will come.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question