<?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: Manish Baral</title>
    <description>The latest articles on DEV Community by Manish Baral (@bmanish).</description>
    <link>https://dev.to/bmanish</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%2F1637982%2F9f91df6d-0510-4c9b-a2ea-3b254e4c7771.jpeg</url>
      <title>DEV Community: Manish Baral</title>
      <link>https://dev.to/bmanish</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bmanish"/>
    <language>en</language>
    <item>
      <title>How to install Node on cPanel shared hosting (without root access)</title>
      <dc:creator>Manish Baral</dc:creator>
      <pubDate>Tue, 18 Jun 2024 09:37:31 +0000</pubDate>
      <link>https://dev.to/bmanish/how-to-install-node-on-cpanel-shared-hosting-without-root-access-ad8</link>
      <guid>https://dev.to/bmanish/how-to-install-node-on-cpanel-shared-hosting-without-root-access-ad8</guid>
      <description>&lt;p&gt;You will need to have access to an SSH command line; not all hosts allow this. I’ve tested this on VentraIP but it may work on other hosts too.&lt;/p&gt;

&lt;p&gt;You’ll need to login via SSH and then run the following commands from the home folder:&lt;/p&gt;

&lt;p&gt;Or you can use the terminal that is in cPanel.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fumt64lz1qq770739plzv.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fumt64lz1qq770739plzv.jpg" alt="screenshot where you can see the link the terminal" width="800" height="107"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(Change the version numbers in the commands below if you’d like to use a more recent version.)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Make a new folder for node&lt;/span&gt;
&lt;span class="nb"&gt;mkdir &lt;/span&gt;node
&lt;span class="nb"&gt;cd &lt;/span&gt;node
&lt;span class="c"&gt;# Download and unzip node&lt;/span&gt;
curl &lt;span class="nt"&gt;-O&lt;/span&gt; https://nodejs.org/dist/v10.15.3/node-v10.15.3-linux-x64.tar.gz
&lt;span class="nb"&gt;tar&lt;/span&gt; &lt;span class="nt"&gt;-xvzf&lt;/span&gt; node-v10.15.3-linux-x64.tar.gz &lt;span class="nt"&gt;--strip-components&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1
&lt;span class="c"&gt;# Add node and npm it to PATH (and do so for future sessions too)&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;/node/bin:&lt;span class="nv"&gt;$PATH&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'export PATH=$HOME/node/bin:$PATH'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that, you should be able to run &lt;code&gt;node&lt;/code&gt; and &lt;code&gt;npm&lt;/code&gt; from any folder.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;YOU ARE DONE! HAPPY CODING!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>node</category>
      <category>cpanel</category>
    </item>
    <item>
      <title>“Remote Work” does NOT mean Work from Home.</title>
      <dc:creator>Manish Baral</dc:creator>
      <pubDate>Tue, 18 Jun 2024 09:29:39 +0000</pubDate>
      <link>https://dev.to/bmanish/remote-work-does-not-mean-work-from-home-2b72</link>
      <guid>https://dev.to/bmanish/remote-work-does-not-mean-work-from-home-2b72</guid>
      <description>&lt;h2&gt;
  
  
  &lt;em&gt;It means Work from Anywhere.&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;Working from anywhere means exactly as it sounds: &lt;em&gt;“working from anywhere”&lt;/em&gt;. Its refers to the ability to perform one’s job tasks from any location with internet access, rather than being confined to a traditional office environment. Whether that’s at home, in the office, or even in a third space like a coffee shop, it provides employees with the flexibility to choose where they accomplish their work.&lt;/p&gt;

&lt;p&gt;Furthermore, working from anywhere fosters inclusion by removing geographical obstacles and giving chances for people who may not be able to access typical office settings owing to considerations such as geography, mobility difficulties, or family commitments.&lt;br&gt;
However, it is vital to recognize that working from anywhere presents its own set of obstacles, such as preserving work-life boundaries, overcoming feelings of isolation, and ensuring dependable internet access. Nonetheless, it signifies a substantial shift in our attitude to work, with an emphasis on outcomes and productivity rather than physical presence.&lt;/p&gt;

&lt;p&gt;To me, “working from anywhere” signifies freedom, flexibility, and efficiency. It means being able to choose where I work based on my personal preferences and circumstances, whether it’s from home, a coffee shop, a co-working space, or while traveling. It also implies being able to balance work and personal life more effectively, as it often allows for greater control over one’s schedule.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pros of working from anywhere:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Fexibility:&lt;/strong&gt; Employees have the freedom to choose their work environment, which can lead to increased satisfaction and productivity.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Work-life balance:&lt;/strong&gt; Working from anywhere allows individuals to better balance their personal and professional responsibilities, reducing stress and improving overall well-being.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost savings:&lt;/strong&gt; Employees can save money on commuting expenses, work attire, and meals, while employers can reduce overhead costs associated with maintaining physical office spaces.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Access to a diverse talent pool:&lt;/strong&gt; Employers can hire the best talent regardless of location, leading to a more diverse and skilled workforce.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Increased productivity:&lt;/strong&gt; Many employees find that they are more productive when working from anywhere due to fewer distractions and the ability to create a customized work environment.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Like anything else in the world, the &lt;em&gt;“work from anywhere”&lt;/em&gt; option has its pros and cons, which are listed below:&lt;/p&gt;

&lt;h2&gt;
  
  
  Cons of working from anywhere:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Communication challenges:&lt;/strong&gt; Remote work can lead to communication difficulties as face-to-face interactions are limited, potentially resulting in miscommunication or feelings of isolation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lack of social interaction:&lt;/strong&gt; Working remotely may lead to feelings of loneliness or isolation as employees miss out on the social aspects of the workplace.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Difficulty unplugging:&lt;/strong&gt; Without a physical separation between work and home, some employees may struggle to disconnect from work, leading to burnout and decreased well-being.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security risks:&lt;/strong&gt; Remote work can pose security risks, as employees may access sensitive information from unsecured networks or devices, increasing the risk of data breaches.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Potential for blurred boundaries:&lt;/strong&gt; Without clear boundaries between work and home life, some employees may find it challenging to maintain a healthy work-life balance, leading to stress and dissatisfaction.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Remote work encompasses more than just working from home. While it includes home-based work, it also extends to other locations, such as co-working spaces, coffee shops, or any place outside the traditional office. The key feature is the flexibility to choose where work is performed, allowing employees to tailor their environment to their needs and preferences. So, remote work is a broader concept that goes beyond the confines of a home office.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>workplace</category>
      <category>workfromhome</category>
      <category>career</category>
    </item>
    <item>
      <title>Redux Toolkit APIs</title>
      <dc:creator>Manish Baral</dc:creator>
      <pubDate>Mon, 17 Jun 2024 17:49:59 +0000</pubDate>
      <link>https://dev.to/bmanish/redux-toolkit-apis-27fj</link>
      <guid>https://dev.to/bmanish/redux-toolkit-apis-27fj</guid>
      <description>&lt;p&gt;Redux Toolkit is a package that provides a set of tools and utilities to simplify the process of working with Redux, a popular state management library for JavaScript applications. One of the key features of the Redux Toolkit is its built-in API, which includes several functions and utilities to streamline Redux development.&lt;/p&gt;

&lt;p&gt;Redux Toolkit is a package that provides a set of tools and utilities to simplify the process of working with Redux, a popular state management library for JavaScript applications. One of the key features of the Redux Toolkit is its built-in API, which includes several functions and utilities to streamline Redux development.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here’s an overview of the Redux Toolkit API:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;createSlice&lt;/code&gt;: This utility function allows you to define a Redux slice, which is a collection of reducer logic for managing a specific slice of the application state. It automatically generates action creators and action types based on the reducer logic you provide, reducing boilerplate code.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;configureStore&lt;/code&gt;: This function is used to create a Redux store with sensible defaults, including support for the Redux DevTools Extension. It simplifies the process of setting up a Redux store by combining several configuration steps into a single function call.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;createAsyncThunk&lt;/code&gt;: This utility function simplifies the process of handling asynchronous logic in Redux by creating action creators that automatically dispatch pending, fulfilled, and rejected actions based on the status of an asynchronous operation (e.g., fetching data from an API).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;createEntityAdapter&lt;/code&gt;: This utility function generates a set of reducer functions and selectors for managing normalized entity states in Redux. It helps organize and manage data in a normalized format, making it easier to work with relational data structures in Redux.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;createReducer&lt;/code&gt;: This utility function allows you to define a reducer function using a map of action type to reducer logic, similar to the approach used in createSlice. It's useful for cases where you need more flexibility in defining reducer logic outside of a slice.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Overall, the Redux Toolkit API aims to simplify common Redux use cases, reduce boilerplate code, and improve developer productivity by providing a set of ergonomic and opinionated tools for working with Redux.&lt;/p&gt;

&lt;h2&gt;
  
  
  How does it handle the Redux data overload issue?
&lt;/h2&gt;

&lt;p&gt;Redux Toolkit doesn’t directly handle data overload issues, but it provides tools and patterns that can help mitigate them:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Normalized State Management:&lt;/strong&gt; The Redux Toolkit encourages normalized state management using utilities like &lt;code&gt;createEntityAdapter&lt;/code&gt;. Normalizing data structures can prevent data overload by organizing data in a structured way, making it easier to manage and update.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Selective Data Loading:&lt;/strong&gt; With &lt;code&gt;createAsyncThunk&lt;/code&gt;, you can implement selective data loading techniques, such as lazy loading or pagination, to load only the data that's needed at any given time. This can help reduce the amount of data stored in the Redux store and improve performance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memoization:&lt;/strong&gt; Redux Toolkit doesn’t handle memoization directly, but you can use memoization libraries like Reselect in conjunction with Redux Toolkit to optimize selectors and prevent unnecessary re-renders caused by data overload.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Middleware and Throttling:&lt;/strong&gt; Redux middleware can be used to implement throttling or debouncing techniques for actions that may trigger data overload. Throttling can help control the rate at which actions are dispatched, preventing excessive updates to the Redux store.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Selective State Slicing:&lt;/strong&gt; Use selectors to retrieve only the necessary parts of the state tree rather than accessing the entire state object. This can help improve performance and reduce memory usage, especially when dealing with large amounts of data.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;While Redux Toolkit provides useful tools and patterns for managing Redux state, it’s important to design your application’s state management strategy carefully to avoid data overload issues. This may involve a combination of normalization, selective data loading, memoization, and other performance optimization techniques tailored to your specific use case.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>redux</category>
      <category>webdev</category>
    </item>
    <item>
      <title>React controlled and uncontrolled hooks</title>
      <dc:creator>Manish Baral</dc:creator>
      <pubDate>Mon, 17 Jun 2024 17:43:47 +0000</pubDate>
      <link>https://dev.to/bmanish/react-controlled-and-uncontrolled-hooks-31b0</link>
      <guid>https://dev.to/bmanish/react-controlled-and-uncontrolled-hooks-31b0</guid>
      <description>&lt;p&gt;In React, controlled and uncontrolled components are patterns used to manage form inputs. React Hooks introduced the concepts of controlled and uncontrolled hooks to manage state within functional components. Here’s an overview:&lt;/p&gt;

&lt;h2&gt;
  
  
  Controlled Hooks:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;useState Hook:&lt;/strong&gt; With controlled hooks, state is managed directly by React. The &lt;code&gt;useState&lt;/code&gt; hook allows you to declare state variables and update them using setter functions provided by React. When a component's state changes, React re-renders the component with the updated state.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;ControlledComponent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setValue&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleChange&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;setValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;input&lt;/span&gt;
      &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt;
      &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="na"&gt;onChange&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleChange&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the input field’s &lt;code&gt;value&lt;/code&gt; is controlled by the value state variable, and updates are handled by the &lt;code&gt;setValue&lt;/code&gt; function.&lt;/p&gt;

&lt;h2&gt;
  
  
  Uncontrolled Hooks:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;useRef Hook:&lt;/strong&gt; Uncontrolled hooks allow you to manage state directly within the DOM rather than through React’s state management system. The &lt;code&gt;useRef&lt;/code&gt; hook creates a mutable ref object whose &lt;code&gt;current&lt;/code&gt; property can hold a value that persists across renders without causing a re-render.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useRef&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;UncontrolledComponent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;inputRef&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useRef&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleClick&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;inputRef&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;input&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;inputRef&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleClick&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Log Value&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the input field’s value is managed directly by the DOM via the &lt;code&gt;inputRef.current.value&lt;/code&gt;, and updates are accessed without involving React's state management system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Choosing Between Controlled and Uncontrolled Hooks:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Controlled Hooks:&lt;/strong&gt; Use controlled hooks when you need React to manage and synchronize the state of form inputs across your application. Controlled components provide a single source of truth for form data, making it easier to track and manage changes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Uncontrolled Hooks:&lt;/strong&gt; Use uncontrolled hooks when you need direct access to DOM elements or when dealing with large forms where controlled components might lead to performance issues. Uncontrolled components can be faster because they don’t trigger re-renders for every state change. However, they may be harder to track and manage, especially in complex applications.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both controlled and uncontrolled hooks have their use cases, and the choice depends on your specific requirements and preferences.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>hooks</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Encryption for API: Make your api request secure</title>
      <dc:creator>Manish Baral</dc:creator>
      <pubDate>Mon, 17 Jun 2024 08:16:16 +0000</pubDate>
      <link>https://dev.to/bmanish/encryption-for-api-make-your-api-request-secure-4668</link>
      <guid>https://dev.to/bmanish/encryption-for-api-make-your-api-request-secure-4668</guid>
      <description>&lt;p&gt;HIPAA compliance requires stringent measures to protect sensitive health information, including encryption for API requests. Here’s a brief overview of how encryption can be implemented for API requests to ensure HIPAA compliance:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Transport Layer Security (TLS):&lt;/strong&gt; Use HTTPS (HTTP Secure) for API communication. TLS encrypts data during transit between the client and the server, ensuring that data exchanged between them remains confidential and secure.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Encryption of Data at Rest:&lt;/strong&gt; Ensure that any sensitive data stored on servers or databases is encrypted. This includes any data that the API might handle, such as patient records, medical history, or other health information.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Minimization:&lt;/strong&gt; Only transmit the minimum necessary data over the API. This principle, known as data minimization, reduces the risk associated with transmitting sensitive information and helps to ensure compliance with HIPAA regulations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Authentication and Authorization:&lt;/strong&gt; Implement robust authentication and authorization mechanisms to control access to the API. This ensures that only authorized users or systems can access sensitive data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tokenization:&lt;/strong&gt; Consider using tokenization for sensitive data. Tokenization replaces sensitive data with unique, randomly generated tokens, reducing the risk associated with storing and transmitting sensitive information.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Audit Trails:&lt;/strong&gt; Implement comprehensive logging and auditing mechanisms to track access to sensitive data through the API. This helps in identifying any unauthorized access attempts or breaches and ensures compliance with HIPAA’s requirements for audit trails.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Regular Security Audits and Penetration Testing:&lt;/strong&gt; Conduct regular security audits and penetration testing to identify and address any vulnerabilities in the API implementation. This proactive approach helps in maintaining the security and integrity of the API environment.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vendor Compliance:&lt;/strong&gt; If you’re using third-party services or vendors for API functionality, ensure that they also adhere to HIPAA compliance standards. This includes verifying that they have appropriate security measures in place to protect sensitive health information.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By implementing these measures, you can help ensure that API requests involving sensitive health information are encrypted and compliant with HIPAA regulations. However, it’s essential to consult with legal and security experts to ensure that your specific implementation meets all relevant regulatory requirements.&lt;br&gt;
Let’s consider an example of how you can implement encryption for API requests in a React application while ensuring HIPAA compliance. For simplicity, let’s assume you’re using the fetch API for making HTTP requests and the crypto library for encryption.&lt;br&gt;
First, you need to ensure that your React application communicates with the server over HTTPS. This ensures that data exchanged between the client and server is encrypted during transit. Most modern servers support HTTPS by default.&lt;br&gt;
Here’s a basic example of how you can encrypt data before sending it in a React component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;crypto&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;crypto&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;API_URL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://your-api-url.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;MyComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setData&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;encryptedData&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setEncryptedData&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;encryptData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Replace 'YOUR_ENCRYPTION_KEY' with your actual encryption key&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;encryptionKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;YOUR_ENCRYPTION_KEY&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;cipher&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;crypto&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createCipher&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;aes-256-cbc&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;encryptionKey&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;encrypted&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;cipher&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;utf8&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hex&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;encrypted&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;cipher&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;final&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hex&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;encrypted&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fetchData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;encrypted&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;encryptData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;API_URL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;POST&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Content-Type&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;encryptedData&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;encrypted&lt;/span&gt; &lt;span class="p"&gt;}),&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;responseData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
      &lt;span class="c1"&gt;// Handle response data&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Error fetching data:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="c1"&gt;// Handle error&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;input&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt;
        &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
        &lt;span class="na"&gt;onChange&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
        &lt;span class="na"&gt;placeholder&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Enter data"&lt;/span&gt;
      &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;fetchData&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Fetch Data&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;MyComponent&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We import the &lt;code&gt;crypto&lt;/code&gt; library to handle encryption.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;encryptData&lt;/code&gt; function encrypts the data using AES encryption with a provided encryption key.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;fetchData&lt;/code&gt; function is an asynchronous function that encrypts the data using &lt;code&gt;encryptData&lt;/code&gt; and sends it to the server using a POST request to the specified API URL.&lt;/li&gt;
&lt;li&gt;Replace &lt;code&gt;'YOUR_ENCRYPTION_KEY'&lt;/code&gt; with your actual encryption key.&lt;/li&gt;
&lt;li&gt;Ensure that your server decrypts the encrypted data using the same encryption algorithm and key.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Remember, this is a simplified example. In a real-world scenario, you would need to handle error cases, manage encryption keys securely, and implement other security measures as per HIPAA compliance requirements. Additionally, consider using libraries like &lt;code&gt;axios&lt;/code&gt; for more robust HTTP requests handling.&lt;/p&gt;

</description>
      <category>api</category>
      <category>hipaa</category>
      <category>javascript</category>
      <category>react</category>
    </item>
  </channel>
</rss>
