Think in Interfaces, Not Implementation: Using React Context API for Better Code Design

  Рет қаралды 467

I Code It

I Code It

Күн бұрын

Пікірлер: 7
@rickvian
@rickvian Жыл бұрын
React lacks of scalable architecture out from the box,based on your videos and article i think you can develop a react scaleable architecture blueprint and open source it sir, that would be cool 😎 (can it be called framework?)
@karlmaddux6209
@karlmaddux6209 Жыл бұрын
I'm using this idea to initialize data models in a react context and I'm enjoying the separation between my business logic from the view logic. But now I sometimes need to trigger re-renders explicitly or make copies of the data object for setting state. Do you have any good strategies for getting pure javaScript business logic to trigger re-renders? I really enjoyed your article, 'Modularizing React Applications with Established UI Patterns.' I wish there was more content like this for web development.
@icodeit.juntao
@icodeit.juntao Жыл бұрын
Thanks @karlmaddux6209 for posting here. To make the React to re-render, generally you should consider to put the data in state and use a setter to update it. Like in the context provider, you pass in both the data and the setter, and down the tree use the setter to change the data, that would automatically trigger a re-render. I guess in most cases you might want to check if the re-render is necessary, although normally the re-render isn't a significant problem.
@casull6447
@casull6447 Жыл бұрын
thank you for this video
@icodeit.juntao
@icodeit.juntao Жыл бұрын
My pleasure, mate! Glad it helps!
@Joao-nn6gn
@Joao-nn6gn Жыл бұрын
In terms of architecture , what does it called this Payment class ? and whered does it belong ? Is it from domain layer? Even tough there's only logic releated to how I present the data or from a layer to give support to presentation like View-Model ?
@icodeit.juntao
@icodeit.juntao Жыл бұрын
Good question Joao. I assume you're saying the PaymentStrategy class (as the Payment itself is a React component that uses the strategy from context)? Yeah, it belongs to the domain layer. As you might have noticed, that class has nothing to do with UI. It's purely data and computing. In more complicated cases, you might need a View-Model (more like a thinner value object in DDD). So I would say a domain model has logic to do the calculation, and view-model is much simpler and only has getter functions (although, in many cases, you can merge them into one object).
😜 #aminkavitaminka #aminokka #аминкавитаминка
00:14
Аминка Витаминка
Рет қаралды 3 МЛН
ТЫ В ДЕТСТВЕ КОГДА ВЫПАЛ ЗУБ😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 3,1 МЛН
Making React Context FAST!
33:34
Jack Herrington
Рет қаралды 89 М.
How Tasking Leads to Simple, Maintainable React Code
16:34
GPT4 Can Write Cleaner React Code Than You Do!
13:06
CoderOne
Рет қаралды 17 М.
Zustand with Context API - An Advanced Pattern
19:12
Cosden Solutions
Рет қаралды 12 М.
THIS stops 90% of C# Developers Learning TDD
19:40
Gui Ferreira
Рет қаралды 14 М.
Don't Use React Context!! Use This instead
13:34
CoderOne
Рет қаралды 28 М.
Design patterns in React
14:37
Cosden Solutions
Рет қаралды 173 М.