S
S
Sergey Suntsev2017-03-27 11:04:15
JavaScript
Sergey Suntsev, 2017-03-27 11:04:15

What is the best way to design a react application?

I am doing SPA, after the completed prototype, it is time to make the application itself. There was a code duplication issue.
To begin with, I wrapped all requests to api in a class and now I call them.
In each component, this class has to be duplicated.
Is it possible to create an additional module with this class and just import it into the rest of the components.

Can someone tell me how to do it better, or suggest manuals where it is written?

I'd be happy if you point me in the right direction

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Kitmanov, 2017-03-27
@GreyCrew

Have you considered Flux/Redux/MobX? These things are much more fun to live in react (although, of course, there is a learning threshold).
Basically, what you are looking for is called the Dependency Injection pattern. You can look for some implementation for React, but, in general, react-redux does just that.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question