<?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: Ansh Sheladiya</title>
    <description>The latest articles on DEV Community by Ansh Sheladiya (@anshsheladiya).</description>
    <link>https://dev.to/anshsheladiya</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%2F1038612%2F0fd65a0a-409a-41c2-95ff-789dc3ef8044.jpeg</url>
      <title>DEV Community: Ansh Sheladiya</title>
      <link>https://dev.to/anshsheladiya</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/anshsheladiya"/>
    <language>en</language>
    <item>
      <title>How to structure React project</title>
      <dc:creator>Ansh Sheladiya</dc:creator>
      <pubDate>Wed, 10 Apr 2024 07:30:00 +0000</pubDate>
      <link>https://dev.to/anshsheladiya/how-to-structure-react-project-4281</link>
      <guid>https://dev.to/anshsheladiya/how-to-structure-react-project-4281</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src
|
+-- assets            
|
+-- components        
|
+-- config           
|
+-- features          
|
+-- hooks             
|
+-- lib               
|
+-- providers         
|
+-- routes            
|
+-- stores            
|
+-- test              
|
+-- types             
|
+-- utils       
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;components: Shared components that grace the entire kingdom&lt;br&gt;
config: The vault of global configurations, env variables, and secrets&lt;br&gt;
features: Feature based modules&lt;br&gt;
hooks: Mystical hooks, shared across the entire realm&lt;br&gt;
libs: re-exporting different libraries preconfigured for the application&lt;br&gt;
providers: Keepers of the application’s life force, the providers&lt;br&gt;
routes: routes configuration&lt;br&gt;
stores: global state stores&lt;br&gt;
test: The arena of trials, where utilities and mock servers prove their mettle&lt;br&gt;
types: base types used across the application&lt;br&gt;
utils: shared utility functions&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Apollo GraphQL - Setup ReactJS</title>
      <dc:creator>Ansh Sheladiya</dc:creator>
      <pubDate>Wed, 10 Apr 2024 07:16:48 +0000</pubDate>
      <link>https://dev.to/anshsheladiya/apollo-graphql-setup-reactjs-4hid</link>
      <guid>https://dev.to/anshsheladiya/apollo-graphql-setup-reactjs-4hid</guid>
      <description>&lt;p&gt;&lt;strong&gt;1. Install Dependencies&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install @apollo/client graphql

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Configure Apollo Client&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// index.js or App.js

import React from 'react';
import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';
import App from './App';

const client = new ApolloClient({
  uri: 'YOUR_GRAPHQL_ENDPOINT_URI',
  cache: new InMemoryCache()
});

ReactDOM.render(
  &amp;lt;ApolloProvider client={client}&amp;gt;
    &amp;lt;App /&amp;gt;
  &amp;lt;/ApolloProvider&amp;gt;,
  document.getElementById('root')
);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Write GraphQL Queries&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// queries.js

import { gql } from '@apollo/client';

export const GET_BOOKS = gql`
  query GetBooks {
    books {
      title
      author
    }
  }
`;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Use Query Component or Hooks&lt;/strong&gt;&lt;br&gt;
Using useQuery hook:&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 from 'react';
import { useQuery } from '@apollo/client';
import { GET_BOOKS } from './queries';

const BookList = () =&amp;gt; {
  const { loading, error, data } = useQuery(GET_BOOKS);

  if (loading) return &amp;lt;p&amp;gt;Loading...&amp;lt;/p&amp;gt;;
  if (error) return &amp;lt;p&amp;gt;Error :(&amp;lt;/p&amp;gt;;

  return (
    &amp;lt;div&amp;gt;
      {data.books.map((book, index) =&amp;gt; (
        &amp;lt;div key={index}&amp;gt;
          &amp;lt;h3&amp;gt;{book.title}&amp;lt;/h3&amp;gt;
          &amp;lt;p&amp;gt;{book.author}&amp;lt;/p&amp;gt;
        &amp;lt;/div&amp;gt;
      ))}
    &amp;lt;/div&amp;gt;
  );
};

export default BookList;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using Query component:&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 from 'react';
import { Query } from '@apollo/client/react/components';
import { GET_BOOKS } from './queries';

const BookList = () =&amp;gt; (
  &amp;lt;Query query={GET_BOOKS}&amp;gt;
    {({ loading, error, data }) =&amp;gt; {
      if (loading) return &amp;lt;p&amp;gt;Loading...&amp;lt;/p&amp;gt;;
      if (error) return &amp;lt;p&amp;gt;Error :(&amp;lt;/p&amp;gt;;

      return (
        &amp;lt;div&amp;gt;
          {data.books.map((book, index) =&amp;gt; (
            &amp;lt;div key={index}&amp;gt;
              &amp;lt;h3&amp;gt;{book.title}&amp;lt;/h3&amp;gt;
              &amp;lt;p&amp;gt;{book.author}&amp;lt;/p&amp;gt;
            &amp;lt;/div&amp;gt;
          ))}
        &amp;lt;/div&amp;gt;
      );
    }}
  &amp;lt;/Query&amp;gt;
);

export default BookList;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Mutations and Subscriptions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For mutations and subscriptions, you can use useMutation and useSubscription hooks respectively provided by Apollo Client.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Controlled and Uncontrolled components in react</title>
      <dc:creator>Ansh Sheladiya</dc:creator>
      <pubDate>Wed, 10 Apr 2024 07:00:38 +0000</pubDate>
      <link>https://dev.to/anshsheladiya/controlled-and-uncontrolled-components-in-react-3896</link>
      <guid>https://dev.to/anshsheladiya/controlled-and-uncontrolled-components-in-react-3896</guid>
      <description>&lt;p&gt;&lt;strong&gt;Controlled Component Example:&lt;/strong&gt;&lt;br&gt;
In a controlled component, the form data is handled by the React component's state. Each form input element has its value controlled by React state, and onChange event handlers are used to update the state whenever the input changes.&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 } from 'react';

const ControlledComponent = () =&amp;gt; {
  const [value, setValue] = useState('');

  const handleChange = (event) =&amp;gt; {
    setValue(event.target.value);
  };

  const handleSubmit = (event) =&amp;gt; {
    event.preventDefault();
    console.log('Submitted value:', value);
    // You can perform further actions like API calls, etc.
  };

  return (
    &amp;lt;form onSubmit={handleSubmit}&amp;gt;
      &amp;lt;input 
        type="text" 
        value={value} 
        onChange={handleChange} 
        placeholder="Enter text" 
      /&amp;gt;
      &amp;lt;button type="submit"&amp;gt;Submit&amp;lt;/button&amp;gt;
    &amp;lt;/form&amp;gt;
  );
};

export default ControlledComponent;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Uncontrolled Component Example:&lt;/strong&gt;&lt;br&gt;
In an uncontrolled component, the form data is handled by the DOM itself. We use refs to get the values of form inputs when needed.&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, { useRef } from 'react';

const UncontrolledComponent = () =&amp;gt; {
  const inputRef = useRef(null);

  const handleSubmit = (event) =&amp;gt; {
    event.preventDefault();
    console.log('Submitted value:', inputRef.current.value);
    // You can perform further actions like API calls, etc.
  };

  return (
    &amp;lt;form onSubmit={handleSubmit}&amp;gt;
      &amp;lt;input 
        type="text" 
        ref={inputRef} 
        placeholder="Enter text" 
      /&amp;gt;
      &amp;lt;button type="submit"&amp;gt;Submit&amp;lt;/button&amp;gt;
    &amp;lt;/form&amp;gt;
  );
};

export default UncontrolledComponent;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>TANSTACK</title>
      <dc:creator>Ansh Sheladiya</dc:creator>
      <pubDate>Wed, 10 Apr 2024 04:49:38 +0000</pubDate>
      <link>https://dev.to/anshsheladiya/tanstack-4f7h</link>
      <guid>https://dev.to/anshsheladiya/tanstack-4f7h</guid>
      <description>&lt;h2&gt;
  
  
  High-quality open-source software for web developers
&lt;/h2&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%2F8y0c0pj850tb0ekek0eo.png" 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%2F8y0c0pj850tb0ekek0eo.png" alt="Image description" width="800" height="372"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;a href="https://tanstack.com/" rel="noopener noreferrer"&gt;
      tanstack.com
    &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>tanstack</category>
      <category>react</category>
      <category>frontend</category>
      <category>webdev</category>
    </item>
    <item>
      <title>The Config File Of Tailwind CSS</title>
      <dc:creator>Ansh Sheladiya</dc:creator>
      <pubDate>Wed, 10 Apr 2024 04:30:37 +0000</pubDate>
      <link>https://dev.to/anshsheladiya/understanding-the-config-file-of-tailwind-css-5eof</link>
      <guid>https://dev.to/anshsheladiya/understanding-the-config-file-of-tailwind-css-5eof</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
  // Paths to scan for classes to purge unused styles in production builds
  purge: ['./src/**/*.html', './src/**/*.js'],

  // Configuration for dark mode
  darkMode: 'class', // 'class' will enable dark mode by adding a class to the &amp;lt;body&amp;gt;, can also be 'media' or 'false'

  // Theme customization
  theme: {
    extend: {
      // Extend default color palette with custom colors
      colors: {
        primary: '#FF0000',
        secondary: '#00FF00',
      },
      // Extend default font family with custom fonts
      fontFamily: {
        sans: ['Roboto', 'sans-serif'],
      },
    },
  },

  // Variants customization
  variants: {
    extend: {
      // Extend variants for backgroundColor utility class to include responsive, hover, focus, and active states
      backgroundColor: ['responsive', 'hover', 'focus', 'active'],
    },
  },

  // Additional plugins to enhance Tailwind's functionality
  plugins: [
    require('@tailwindcss/forms'), // Plugin for styling form elements
    require('@tailwindcss/typography'), // Plugin for styling typography
  ],
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>tailwindcss</category>
      <category>react</category>
      <category>nextjs</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
