<?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: Teerth Sankesara</title>
    <description>The latest articles on Forem by Teerth Sankesara (@tsankesara).</description>
    <link>https://forem.com/tsankesara</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%2F609897%2F25c1d2f3-2b9c-4849-8a51-4db625101bd4.jpeg</url>
      <title>Forem: Teerth Sankesara</title>
      <link>https://forem.com/tsankesara</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/tsankesara"/>
    <language>en</language>
    <item>
      <title>React Project Organization: Best Practices for Developers at Any Level</title>
      <dc:creator>Teerth Sankesara</dc:creator>
      <pubDate>Tue, 30 Jul 2024 15:20:53 +0000</pubDate>
      <link>https://forem.com/tsankesara/react-project-organization-best-practices-for-developers-at-any-level-238</link>
      <guid>https://forem.com/tsankesara/react-project-organization-best-practices-for-developers-at-any-level-238</guid>
      <description>&lt;h1&gt;
  
  
  Mastering Your React Project Structure: A Friendly Guide for All Levels
&lt;/h1&gt;

&lt;p&gt;Welcome to the world of React! Whether you're just starting out, have a few projects under your belt, or are a seasoned pro, organizing your project can sometimes feel like navigating a maze. But don't worry, I've got you covered! In this post, we'll explore how to structure your React projects to keep them neat, scalable, and easy to manage. Let's dive in!&lt;/p&gt;

&lt;h2&gt;
  
  
  For Beginners: Keeping It Simple and Sweet
&lt;/h2&gt;

&lt;p&gt;If you're new to React, you probably just want to get things working without worrying too much about where to put your files. That's totally fine! At this stage, it's all about learning the basics and getting comfortable with the framework.&lt;/p&gt;

&lt;h3&gt;
  
  
  Basic Folder Structure:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Components&lt;/strong&gt;: This folder contains all React components, including everything from basic buttons to more complex forms. Organizing components in one place helps beginners easily find and work with them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hooks&lt;/strong&gt;: Custom hooks are stored in a separate folder. Hooks are essential for managing state and side effects in functional components.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tests&lt;/strong&gt;: All test files are placed in a single folder, separate from the code they test. This separation helps maintain clarity and organization in the project.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/src
  /components
  /hooks
  /tests
  index.js
  App.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This setup is straightforward and helps you keep track of your components and hooks without getting overwhelmed.&lt;/p&gt;

&lt;h2&gt;
  
  
  For Intermediate Developers: Organizing and Scaling Up
&lt;/h2&gt;

&lt;p&gt;As you get more comfortable with React and start building more complex applications, it's time to add some structure to your project. This is where things get a bit more organized, and you start thinking about scalability.&lt;/p&gt;

&lt;h3&gt;
  
  
  Intermediate Folder Structure:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Assets&lt;/strong&gt;: This is where you stash all your images, global CSS files, and any other non-JavaScript assets. It's like your app's toolbox.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Context&lt;/strong&gt;: If you're using React's Context API for state management, this is where you'll keep all those context-related files. It helps in managing the state across different parts of your app.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data&lt;/strong&gt;: Store your JSON files or any other data constants here. Keeping data separate from your logic and UI makes it easier to manage and update.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pages&lt;/strong&gt;: For apps with multiple pages, it's a good idea to have a separate folder for each page. This way, each page can have its own set of components and styles.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Utils&lt;/strong&gt;: Utility functions and helpers go here. These are the little snippets of code that make your life easier by handling common tasks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/src
  /assets
  /components
  /context
  /data
  /pages
  /utils
  index.js
  App.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This structure not only helps you stay organized but also makes your codebase easier to navigate and maintain. It’s like upgrading from a simple toolbox to a well-organized workshop.&lt;/p&gt;

&lt;h2&gt;
  
  
  For Advanced Developers: Crafting a Robust and Scalable Architecture
&lt;/h2&gt;

&lt;p&gt;At the advanced level, you’re likely working on large-scale applications or projects that require robust architecture. The goal here is to create a highly modular and maintainable codebase. This structure is designed to handle complexity with grace.&lt;/p&gt;

&lt;h3&gt;
  
  
  Advanced Folder Structure:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Public&lt;/strong&gt;: Contains static files like your &lt;code&gt;index.html&lt;/code&gt;, which is the entry point of your app. It’s like the welcome mat of your project.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Src&lt;/strong&gt;: The main hub of your application, neatly divided into several subdirectories.

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Assets&lt;/strong&gt;: Further divided into categories like audios, icons, images, and videos. It’s your multimedia corner.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Components&lt;/strong&gt;: Organized by functionality or feature, with each component having its own folder. This includes the component file, its styles, and any related assets.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Contexts&lt;/strong&gt;: For managing state and contexts across your app. It’s like the control room for your app’s state.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Services&lt;/strong&gt;: If your app talks to APIs or performs other backend tasks, those logic pieces go here.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Store&lt;/strong&gt;: For global state management using libraries like Redux or MobX. It’s your app’s memory bank.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hooks&lt;/strong&gt;: Custom hooks, organized by their purpose. Think of these as your app’s special abilities.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pages&lt;/strong&gt;: Each major page or view of your app gets its own folder. This keeps your app’s structure tidy and easy to follow.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Utils&lt;/strong&gt;: Advanced utility functions and higher-order components (HOCs) live here. These are the tools that make your app smarter and more efficient.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/public
  index.html
/src
  /assets
    /audios
    /icons
    /images
    /videos
  /components
    /Button
      index.jsx
      button.module.css
    /Modal
      index.jsx
      modal.module.css
  /contexts
  /services
  /store
  /hooks
  /pages
  /utils
  index.js
  App.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This structure is like a well-oiled machine, designed to handle the complexity of large-scale apps with ease. It ensures that everything has its place, making the codebase easy to navigate and maintain.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping It All Up: Finding Your Perfect Fit
&lt;/h2&gt;

&lt;p&gt;Choosing the right folder structure for your React project depends on your project's needs and your team's workflow. Start simple if you're a beginner, and gradually adopt more sophisticated structures as your project grows and your skills improve. Remember, there's no one-size-fits-all solution—adapt these structures to what works best for you and your team.&lt;/p&gt;

&lt;p&gt;A well-organized project not only makes development smoother but also helps when collaborating with others or bringing new developers on board. As you continue to work with React, don't be afraid to refine and tweak your structure. The goal is always to make your codebase as clean, efficient, and maintainable as possible.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;




</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>react</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Hosting Static Websites on Heroku</title>
      <dc:creator>Teerth Sankesara</dc:creator>
      <pubDate>Wed, 07 Apr 2021 08:28:33 +0000</pubDate>
      <link>https://forem.com/tsankesara/hosting-static-websites-on-heroku-4h6n</link>
      <guid>https://forem.com/tsankesara/hosting-static-websites-on-heroku-4h6n</guid>
      <description>&lt;p&gt;Hey there, so I've been developing React web-apps for a year now, but recently I've decided to go for the good old method of web development &lt;strong&gt;DOM&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So I took up an Udemy course by Brad Traversy to create 50 projects solely based on HTML, CSS and JS.&lt;/p&gt;

&lt;p&gt;After I've created my first project it hit to that I had no idea on how to host an static website for free, I know github gives us this option but I've worked with Heroku so much that I wanted nothing more that to use it here as well, and after some googling I've found some outdated-solution.&lt;br&gt;
I decided to write an clean solution here.&lt;/p&gt;
&lt;h3&gt;
  
  
  So Here comes the good part.
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://onepiece-cards.herokuapp.com" rel="noopener noreferrer"&gt;Sites Hosted Here&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/tsankesara/50Days-Project-Challange/tree/main/ExpandingCards" rel="noopener noreferrer"&gt;Code Here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So as Heroku doesn't allow us to host serve static content I'll be using php to host it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1 =&amp;gt;&lt;/strong&gt; Create an index.php file in your root directory.&lt;br&gt;
&lt;strong&gt;Step 2 =&amp;gt;&lt;/strong&gt; Insert Following Code (Where index.html in you main html file)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php 
define('PROJECT_ROOT_PATH', __DIR__);

include_once(PROJECT_ROOT_PATH . '/index.html'); 
?&amp;gt;
```

` 

**Step 3 =&amp;gt;** Create an composer.json file in root and fill it wil `{}` (php server require an composer.json file, it can be an empty json but it is still required)

**Step 4 =&amp;gt;** Run following commend to create and commit an local git repository 
`git init`
`git add .`
`git commit -m 'first commit'`

**Step 5 =&amp;gt;** Create an [Heroku Account](https://signup.heroku.com/) and Install [Heroku Cli](https://devcenter.heroku.com/articles/heroku-cli).

**Step 6 =&amp;gt;** Run `heroku login` on you cmd or terminal.

**Step 7 =&amp;gt;** Run `heroku apps:create &amp;lt;APP_NAME&amp;gt;`

**Step 8 =&amp;gt;** Run `git push heroku &amp;lt;BRANCH_NAME&amp;gt;`

### So it concludes us deploying static websites on Heroku. 

*Please leave an comment if this helped or if you faced any issues, I'd be more then happy to help you. Follow me if you liked this content I'd be making post on daily bases about my journey through making these 50 projects.*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>javascript</category>
      <category>heroku</category>
      <category>php</category>
    </item>
  </channel>
</rss>
