<?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>Forem: muflih1</title>
    <description>The latest articles on Forem by muflih1 (@muflihkp).</description>
    <link>https://forem.com/muflihkp</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%2F876144%2Fdfd07cb6-d26d-4507-b9f2-31c32b49cf16.png</url>
      <title>Forem: muflih1</title>
      <link>https://forem.com/muflihkp</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/muflihkp"/>
    <language>en</language>
    <item>
      <title>Why does the textarea rows count not decrease when content is removed?</title>
      <dc:creator>muflih1</dc:creator>
      <pubDate>Fri, 10 May 2024 10:52:17 +0000</pubDate>
      <link>https://forem.com/muflihkp/why-does-the-textarea-rows-count-not-decrease-when-content-is-removed-3kab</link>
      <guid>https://forem.com/muflihkp/why-does-the-textarea-rows-count-not-decrease-when-content-is-removed-3kab</guid>
      <description>&lt;p&gt;When I don't set the rows to state or textAreaRef.current.rows = calculatedRows, the console log properly increases and decreases the calculatedRows. However, as soon as I set the calculatedRows to the state or textAreaRef.current.rows = calculatedRows, it increases the rows but does not decrease them; it stays at the last calculatedRows.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useState, useRef, useEffect } from "react";
import ReactDOM from "react-dom";
import styled from "styled-components";

const TextArea = styled.textarea`
  padding: 2px;
  resize: none;
  overflow-y: hidden;
  line-height: 1.5;
`;

function App() {
  const [val, setVal] = useState("");
  const textAreaRef = useRef(null);
  const [rows, setRows] = useState(1);

  const resizeTextArea = () =&amp;gt; {
    const lineHeight = parseInt(
      window.getComputedStyle(textAreaRef.current).lineHeight
    );
    const calculatedRows = Math.floor(
      textAreaRef.current.scrollHeight / lineHeight
    );
    console.log(calculatedRows);
    setRows(calculatedRows);
  };

  useEffect(() =&amp;gt; {
    resizeTextArea();
  }, [val]);

  const onChange = (e) =&amp;gt; {
    setVal(e.target.value);
  };

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;TextArea ref={textAreaRef} value={val} onChange={onChange} rows={rows} /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

const rootElement = document.getElementById("root");
ReactDOM.render(&amp;lt;App /&amp;gt;, rootElement);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I expected the number of rows in the textarea to decrease when content is removed, but it only increases. I've tried using setRows(calculatedRows) and textAreaRef.current.rows = calculatedRows to update the number of rows but encountered the same issue.&lt;/p&gt;

</description>
      <category>textarea</category>
      <category>autoresize</category>
      <category>react</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Proper Method for Storing User Data on the Client Side in React for Authentication</title>
      <dc:creator>muflih1</dc:creator>
      <pubDate>Fri, 18 Aug 2023 05:50:34 +0000</pubDate>
      <link>https://forem.com/muflihkp/proper-method-for-storing-user-data-on-the-client-side-in-react-for-authentication-2igi</link>
      <guid>https://forem.com/muflihkp/proper-method-for-storing-user-data-on-the-client-side-in-react-for-authentication-2igi</guid>
      <description>&lt;p&gt;I'm developing a React application and need to securely store logged-in user information on the client side for authentication purposes. I'm currently exploring options such as localStorage, sessionStorage, and state management libraries like Redux. My concern is to ensure data privacy and security while maintaining efficient performance. I'm seeking guidance on the recommended approach to handle this situation effectively within the React ecosystem. Are there any industry best practices or established patterns for managing user data on the client side? Thank you for your insights and advice!&lt;/p&gt;

</description>
      <category>react</category>
      <category>client</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>how i can build a rest api using python without using any framework</title>
      <dc:creator>muflih1</dc:creator>
      <pubDate>Mon, 13 Jun 2022 04:26:43 +0000</pubDate>
      <link>https://forem.com/muflihkp/how-i-can-build-a-rest-api-using-python-without-using-any-framework-l7p</link>
      <guid>https://forem.com/muflihkp/how-i-can-build-a-rest-api-using-python-without-using-any-framework-l7p</guid>
      <description></description>
    </item>
  </channel>
</rss>
