<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: MDFC</title>
    <description>The latest articles on DEV Community by MDFC (@lucidmdfc).</description>
    <link>https://dev.to/lucidmdfc</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1399105%2F4bd76886-9dec-4967-b459-0bdde0f6cbe5.jpeg</url>
      <title>DEV Community: MDFC</title>
      <link>https://dev.to/lucidmdfc</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lucidmdfc"/>
    <language>en</language>
    <item>
      <title>Service layer with Tanstack and Contexte API</title>
      <dc:creator>MDFC</dc:creator>
      <pubDate>Sun, 19 May 2024 15:12:21 +0000</pubDate>
      <link>https://dev.to/lucidmdfc/service-layer-with-tanstack-and-contexte-api-1b02</link>
      <guid>https://dev.to/lucidmdfc/service-layer-with-tanstack-and-contexte-api-1b02</guid>
      <description>&lt;p&gt;I have decided to use a service layer to manage my API/server calls in my React app. I'm using Tanstack Query (useQuery and useMutation) in my components and an API context. I aim to maintain maximum separation, especially between the service layer and the rest of the flow. Here is my current approach:&lt;/p&gt;

&lt;p&gt;1 Creating a Specific Feature Context: I have a context (let's call it TanstackQueryContext).&lt;/p&gt;

&lt;p&gt;2 Provider as a Data Provider: The provider focuses on one mission: sharing this context with components. Each component (TSX file) uses the useContext hook to get updates from the provider. Notice: TSX will not directly import Custom Hooks in this case&lt;/p&gt;

&lt;p&gt;3 Inversion of Control: The Tanstack Query hooks import and use the service layer interface to manage API calls.&lt;/p&gt;

&lt;p&gt;Is this approach Healthy and enough? Or may be it needs to be reviewed/coorect or replaced with a better one? Thank you in advance&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
