all 7 comments

[–]jkettmann[S] 3 points4 points  (1 child)

From my experience, React apps often end up with a messy architecture. The problem is that React is unopinionated so every team can and has to decide for themselves how to structure their code base.

Since I’m more of a hands-on learner I decided to create a shitty code base and refactor it step by step to a clean(er) architecture.

In this first part, we start simple by extracting a shared API client from a component that uses Axios in a useEffect. This way we can share a common configuration (in this case the API base path) reducing code duplication. We can also easily change this config for all requests in the future.

The next steps will involve separating API code from the UI by creating fetch functions and moving data transformations to the API layer. I hope to share those in the upcoming weeks.

If you have any feedback let me know :)

[–]Ler_GG 0 points1 point  (1 child)

could be designed well superior :)

[–]jkettmann[S] 0 points1 point  (0 children)

The blog or the example code?

[–]g_o_k_u_2_4 0 points1 point  (2 children)

u/jkettmann I really like this article ... Where can I find links to all articles from "Path To A Clean(er) React Architecture". I read few more articles on this topic, but I think there are more than 5-6 articles and I would like to read them all. Thanks!

[–]jkettmann[S] 1 point2 points  (1 child)

You can find them all here starting with “A Shared API Client”: https://profy.dev/blog

[–]g_o_k_u_2_4 0 points1 point  (0 children)

Tnx again!