<?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: David Poulain</title>
    <description>The latest articles on DEV Community by David Poulain (@david_poulain).</description>
    <link>https://dev.to/david_poulain</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3391169%2F5d17b72f-6642-4b03-8814-f623accaef23.jpeg</url>
      <title>DEV Community: David Poulain</title>
      <link>https://dev.to/david_poulain</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/david_poulain"/>
    <language>en</language>
    <item>
      <title>Stop using React hooks for every things</title>
      <dc:creator>David Poulain</dc:creator>
      <pubDate>Wed, 13 Aug 2025 08:11:58 +0000</pubDate>
      <link>https://dev.to/david_poulain/stop-using-react-hooks-for-every-things-p73</link>
      <guid>https://dev.to/david_poulain/stop-using-react-hooks-for-every-things-p73</guid>
      <description>&lt;p&gt;Okay, this may sounds a little weird from a front-end web developper specialized in React but trust me, I'm sure this is a really valid point.&lt;/p&gt;

&lt;p&gt;When you learn React, you want to do every things in React. It's like your new toy, you want to discover it, &lt;strong&gt;you want to master it&lt;/strong&gt;. Later when you gain some experience  and if you manage to have a better overview you may realize that when you can &lt;strong&gt;it's better to write pure native html / css code&lt;/strong&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A bit of explanation if your are not familiar with React : React hooks are built-in functions that let you use state, lifecycle features, and other React capabilities inside functional components.&lt;br&gt;
The most common ones are useState, useEffect, useContext, and useRef. They're incredibly useful — but also often overused for things that could be done with plain HTML, CSS, or browser APIs.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To be more concrete, I'll give you three examples : native popover, handle forms and display or hide things in a list.&lt;/p&gt;

&lt;h2&gt;
  
  
  Native popover
&lt;/h2&gt;

&lt;p&gt;There is a recent API Popover that lets you use universal attributes to designate an element and display it above the rest of the content.&lt;br&gt;
So rather than having a state and function to display and hide that popover you can use this new API and just write :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvl1qx1ljteuywmg6t0ax.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvl1qx1ljteuywmg6t0ax.png" alt="code snipet that illustrate a component that use native popover api" width="800" height="755"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I remember the first time I heard about this, I really wanted this new API to be well support on every browser and when I used it for the first it was a relief not to have to create a custom solution, I was like : "Oh yeah finaly we can do something with pure native html code".&lt;/p&gt;

&lt;p&gt;Next time you'll want to make a popover component I can only invite you to give it a try. &lt;/p&gt;

&lt;h2&gt;
  
  
  Handle forms
&lt;/h2&gt;

&lt;p&gt;Handling forms is like one of the most common thing in web development, and some times I have the feeling that we over complicate things.&lt;/p&gt;

&lt;p&gt;Like for a basic login or registration form maybe you'll use some state to control input user email and password, you would create a function with a regex to check password or email format, you would make a hook to handle all of this and make the api call but a lot of this things can be handle with pure html code, and I have the feeling that we are forgeting that on the road to learn React.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5rjz9hdgh8o0ay9vmuk8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5rjz9hdgh8o0ay9vmuk8.png" alt="code snipet that illustrate register form handle in pure html" width="800" height="915"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And that's it, just with that you form is working. This example is very basic but it's to show that for a not too complicated form without much security you can use pure html.&lt;/p&gt;

&lt;h2&gt;
  
  
  Display and hide things in a list
&lt;/h2&gt;

&lt;p&gt;There is something very powerfull in css that you can use to hide or display things in a list (rather than using a state), this thing is called : &lt;code&gt;:has()&lt;/code&gt;.&lt;br&gt;
This is a pseudo-class that let's you style an element based on its descendants or state of its children. it's like a "parent selector" that allows CSS to say, "Style this element if it contains something specific."&lt;/p&gt;

&lt;p&gt;So for example you can use it to display or hide things based on a checkbox. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frlxu8gcvo1xbyh7u5zev.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frlxu8gcvo1xbyh7u5zev.png" alt="code snipet that illustrate the pseudo class :has()" width="800" height="555"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One of the great thing about this solution is performance : there is no need for a DOM and Virtual DOM reconciliation because there is no props change. It's so fast, the response time is instantaneous.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sometimes native is not enough
&lt;/h2&gt;

&lt;p&gt;Of course sometimes you can't only use pure html / css code because the feature you are making is too complicated or you customer want a very specific behavior that you can't do with pure html / css code. &lt;/p&gt;

&lt;p&gt;So my point is to make you take a step backward, get a better overview and ask yourself if the feature you are developping need so much specific React functions or can you make it with basic and universal code ?&lt;/p&gt;

&lt;p&gt;You need to think about performance and optimization so that's why I ask myself for each feature, what is the best option and If I can use pure html / css, that's what I do.&lt;/p&gt;

&lt;p&gt;Thanks for reading this first post and feel free to share your thoughts and opinions about this topic !&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>html</category>
      <category>css</category>
    </item>
  </channel>
</rss>
