<?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: jaredsurya</title>
    <description>The latest articles on DEV Community by jaredsurya (@jaredsurya).</description>
    <link>https://dev.to/jaredsurya</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%2F820150%2F62bd6f28-a046-4752-b828-a5ba756e9809.jpeg</url>
      <title>DEV Community: jaredsurya</title>
      <link>https://dev.to/jaredsurya</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jaredsurya"/>
    <language>en</language>
    <item>
      <title>Nothing New Here</title>
      <dc:creator>jaredsurya</dc:creator>
      <pubDate>Tue, 19 Sep 2023 20:50:21 +0000</pubDate>
      <link>https://dev.to/jaredsurya/nothing-new-here-3b0g</link>
      <guid>https://dev.to/jaredsurya/nothing-new-here-3b0g</guid>
      <description>&lt;p&gt;Yeah so, what?&lt;/p&gt;

</description>
      <category>report</category>
      <category>whiskey</category>
      <category>ngsa</category>
    </item>
    <item>
      <title>Using Leaflet JS library to create responsively programmed maps using React</title>
      <dc:creator>jaredsurya</dc:creator>
      <pubDate>Mon, 24 Apr 2023 18:52:12 +0000</pubDate>
      <link>https://dev.to/jaredsurya/using-leaflet-js-library-to-create-responsively-programmed-maps-using-react-5h11</link>
      <guid>https://dev.to/jaredsurya/using-leaflet-js-library-to-create-responsively-programmed-maps-using-react-5h11</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Leaflet is a popular open-source JavaScript library for creating interactive maps. It provides a lightweight and easy-to-use API for creating maps and markers. The Leaflet npm package makes it easy to integrate Leaflet with your React application, allowing you to create interactive maps with markers and popups. By using Leaflet, you can take advantage of its many features and benefits, such as its support for various map providers, its customizable markers, and its ability to handle large amounts of data. &lt;/p&gt;

&lt;p&gt;With Leaflet, you can create powerful and interactive maps that enhance the user experience of your React application. In this tutorial, we will be using the Leaflet npm package to create useful maps for our Rails application. We will cover how to use programmed markers, make them clickable, and program their location.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-requisites
&lt;/h2&gt;

&lt;p&gt;Before you start with this tutorial, you should have the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Basic knowledge of HTML, CSS, and JavaScript
Familiarity with Node.js and npm (Node Package Manager)&lt;/li&gt;
&lt;li&gt;An up-to-date version of Node.js installed on your system (we recommend version 14 or higher)&lt;/li&gt;
&lt;li&gt;An up-to-date version of npm installed on your system (we recommend version 6 or higher)&lt;/li&gt;
&lt;li&gt;An understanding of React and its basic concepts&lt;/li&gt;
&lt;li&gt;A code editor such as Visual Studio Code or Sublime Text installed on your system&lt;/li&gt;
&lt;li&gt;A modern web browser such as Chrome, Firefox, or Safari&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you're new to React or Leaflet, we recommend that you take some time to familiarize yourself with the basics before starting this tutorial. Here are some resources that can help you get started:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://legacy.reactjs.org/docs/getting-started.html"&gt;React Documentation&lt;/a&gt;&lt;br&gt;
&lt;a href="https://leafletjs.com/index.html"&gt;Leaflet Documentation&lt;/a&gt;&lt;br&gt;
&lt;a href="https://react.dev/learn/tutorial-tic-tac-toe"&gt;Official React Tutorial&lt;/a&gt;&lt;br&gt;
&lt;a href="https://leafletjs.com/examples/quick-start/"&gt;Official Leaflet tutorial&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Additionally, to follow this tutorial, you'll need to have the following dependencies installed in your project:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;react&lt;/code&gt; and &lt;code&gt;react-dom&lt;/code&gt;: These are the core React libraries that enable you to build React components.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;leaflet&lt;/code&gt;: This is the JavaScript library that we'll be using to create and interact with the Leaflet map.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;react-leaflet&lt;/code&gt;: This is the React wrapper for Leaflet that allows you to use Leaflet with React components.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can install these dependencies by running the following command in your project directory:&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 react react-dom leaflet react-leaflet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: If you're using Yarn instead of npm, you can install these dependencies by running the following command in your project directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add react react-dom leaflet react-leaflet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure to save these dependencies as devDependencies by adding the --save-dev flag to the install command if you're using npm.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation and Set-up
&lt;/h2&gt;

&lt;p&gt;Before we get started, make sure that you have Node.js and npm installed on your system, as well as a code editor such as Visual Studio Code or Sublime Text.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a new React project
&lt;/h3&gt;

&lt;p&gt;To create a new React project, open up your terminal and navigate to the directory where you want to create the project. Then run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app my-map-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create a new React project called &lt;code&gt;my-map-app&lt;/code&gt; in the current directory.&lt;br&gt;
Replace &lt;code&gt;my-map-app&lt;/code&gt; with your own apps name.&lt;/p&gt;
&lt;h3&gt;
  
  
  Installing dependencies
&lt;/h3&gt;

&lt;p&gt;Next, we need to install the &lt;code&gt;leaflet&lt;/code&gt; and &lt;code&gt;react-leaflet&lt;/code&gt; packages that we'll be using to create our map. To install these packages, navigate to your project directory (&lt;code&gt;my-map-app&lt;/code&gt;) in your terminal and run the following command:&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 leaflet react-leaflet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Adding Leaflet CSS
&lt;/h3&gt;

&lt;p&gt;Before we can use Leaflet, we need to add its CSS file to our project. To do this, open up the &lt;code&gt;public/index.html&lt;/code&gt; file in your project directory and add the following line inside the &lt;/p&gt; element:&lt;br&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;link
  rel="stylesheet"
  href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"
  integrity="sha384-pFeFNVIfdvyD31yC5j5w5LB5wUzL1U/k8Z9X9xrwnKGGnUz0nFlMfPaa15tx2qqn"
  crossorigin=""
/&amp;gt;

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

&lt;/div&gt;


&lt;p&gt;This will load the Leaflet CSS file from a CDN (Content Delivery Network) and make it available to our project.&lt;/p&gt;
&lt;h3&gt;
  
  
  Testing the setup
&lt;/h3&gt;

&lt;p&gt;Finally, we can test our setup by running the following command in our project directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will start the development server and open up a new browser window with our React app. If everything is set up correctly, you should see the default React app homepage.&lt;/p&gt;

&lt;p&gt;That's it! You've now set up your React project and installed the necessary dependencies. In the next section, we'll start building our Leaflet map component.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building the Map Component
&lt;/h2&gt;

&lt;p&gt;Now that we have our React project set up and the necessary dependencies installed, we can start building our Leaflet map component.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding the Map Component
&lt;/h3&gt;

&lt;p&gt;First, create a new file called &lt;code&gt;Map.js&lt;/code&gt; in the &lt;code&gt;src&lt;/code&gt; directory of your React project. In this file, we'll create a new React component that will render our Leaflet map.&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, useEffect } from "react";
import { MapContainer, TileLayer, Marker, Popup } from "react-leaflet";
import "leaflet/dist/leaflet.css";

function Map() {
  const mapRef = useRef(null);

  useEffect(() =&amp;gt; {
    if (mapRef.current) {
      const { current: map } = mapRef;
      map.setView([51.505, -0.09], 13);
    }
  }, []);

  return (
    &amp;lt;MapContainer
      center={[51.505, -0.09]}
      zoom={13}
      style={{ height: "100vh", width: "100%" }}
      whenCreated={mapInstance =&amp;gt; (mapRef.current = mapInstance)}
    &amp;gt;
      &amp;lt;TileLayer
        url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
        attribution='Map data &amp;amp;copy; &amp;lt;a href="https://www.openstreetmap.org/"&amp;gt;OpenStreetMap&amp;lt;/a&amp;gt; contributors'
      /&amp;gt;
      &amp;lt;Marker position={[51.505, -0.09]}&amp;gt;
        &amp;lt;Popup&amp;gt;
          A pretty CSS3 popup. &amp;lt;br /&amp;gt; Easily customizable.
        &amp;lt;/Popup&amp;gt;
      &amp;lt;/Marker&amp;gt;
    &amp;lt;/MapContainer&amp;gt;
  );
}

export default Map;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this component, we're importing the &lt;code&gt;MapContainer&lt;/code&gt;, &lt;code&gt;TileLayer&lt;/code&gt;, &lt;code&gt;Marker&lt;/code&gt;, and &lt;code&gt;Popup&lt;/code&gt; components from &lt;code&gt;react-leaflet&lt;/code&gt;. We're also using the &lt;code&gt;useRef&lt;/code&gt; hook to get a reference to the Leaflet map instance, and the &lt;code&gt;useEffect&lt;/code&gt; hook to set the initial view of the map.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;MapContainer&lt;/code&gt; component is the top-level component for our map, and takes in several props including &lt;code&gt;center&lt;/code&gt; (the initial center point of the map), &lt;code&gt;zoom&lt;/code&gt; (the initial zoom level of the map), and &lt;code&gt;style&lt;/code&gt; (the CSS style for the map container). We're also using the &lt;code&gt;whenCreated&lt;/code&gt; prop to set the &lt;code&gt;mapRef&lt;/code&gt; to the Leaflet map instance.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;TileLayer&lt;/code&gt; component is responsible for displaying the map tiles. In this example, we're using the OpenStreetMap tile server, but you can also use other tile servers like Mapbox or Google Maps.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;Marker&lt;/code&gt; component is used to display a clickable marker on the map, and takes in a &lt;code&gt;position&lt;/code&gt; prop to set the position of the marker. The &lt;code&gt;Popup&lt;/code&gt; component is used to display a tooltip when the user clicks on the marker.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding Clickable Markers
&lt;/h3&gt;

&lt;p&gt;To make our markers clickable, we need to add an event handler to the &lt;code&gt;Marker&lt;/code&gt; component. In the &lt;code&gt;Map.js&lt;/code&gt; file, add the following function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function handleClick(e) {
  console.log(e.latlng);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This function logs the latitude and longitude of the clicked location to the console. Next, update the &lt;code&gt;Marker&lt;/code&gt; component to include the &lt;code&gt;eventHandlers&lt;/code&gt; prop:&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;Marker position={[51.505, -0.09]} eventHandlers={{ click: handleClick }}&amp;gt;
  &amp;lt;Popup&amp;gt;
    A pretty CSS3 popup. &amp;lt;br /&amp;gt; Easily customizable.
  &amp;lt;/Popup&amp;gt;
&amp;lt;/Marker&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Integration with React
&lt;/h2&gt;

&lt;p&gt;Now that we have our Leaflet map component built, we need to integrate it with our React app.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding the Map Component to App.js
&lt;/h3&gt;

&lt;p&gt;In your &lt;code&gt;App.js&lt;/code&gt; file, import the &lt;code&gt;Map&lt;/code&gt; component and add it to your app's main layout.&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 Map from "./Map";

function App() {
  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;header className="App-header"&amp;gt;
        &amp;lt;h1&amp;gt;My React Leaflet Map&amp;lt;/h1&amp;gt;
      &amp;lt;/header&amp;gt;
      &amp;lt;Map /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we're importing the &lt;code&gt;Map&lt;/code&gt; component and rendering it below the header. You can customize the layout of your app as needed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding Custom Markers
&lt;/h3&gt;

&lt;p&gt;To add custom markers to your map, you can create a new component that renders the marker and its associated popup. For example, create a new file called &lt;code&gt;CustomMarker.js&lt;/code&gt; in the &lt;code&gt;src&lt;/code&gt; directory:&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 { Marker, Popup } from "react-leaflet";

function CustomMarker({ position, text }) {
  return (
    &amp;lt;Marker position={position}&amp;gt;
      &amp;lt;Popup&amp;gt;{text}&amp;lt;/Popup&amp;gt;
    &amp;lt;/Marker&amp;gt;
  );
}

export default CustomMarker;

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

&lt;/div&gt;



&lt;p&gt;In this component, we're using the &lt;code&gt;Marker&lt;/code&gt; and &lt;code&gt;Popup&lt;/code&gt; components from &lt;code&gt;react-leaflet&lt;/code&gt; to display the marker and its associated popup. The &lt;code&gt;position&lt;/code&gt; prop sets the position of the marker, and the &lt;code&gt;text&lt;/code&gt; prop sets the content of the popup.&lt;/p&gt;

&lt;p&gt;To use this custom marker in our &lt;code&gt;Map&lt;/code&gt; component, we can import it and add it to the &lt;code&gt;Map&lt;/code&gt; component's JSX:&lt;br&gt;
&lt;/p&gt;

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

function Map() {
  // ...

  return (
    &amp;lt;MapContainer
      // ...
    &amp;gt;
      &amp;lt;TileLayer
        // ...
      /&amp;gt;
      &amp;lt;CustomMarker position={[51.5, -0.1]} text="Hello, world!" /&amp;gt;
    &amp;lt;/MapContainer&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we're adding a new &lt;code&gt;CustomMarker&lt;/code&gt; component to the &lt;code&gt;Map&lt;/code&gt; component, with a position of &lt;code&gt;[51.5, -0.1]&lt;/code&gt; and text of "Hello, world!".&lt;/p&gt;

&lt;h2&gt;
  
  
  Best Practices
&lt;/h2&gt;

&lt;p&gt;When working with Leaflet maps in a React app, there are a few best practices you should keep in mind to ensure your app runs smoothly and efficiently.&lt;/p&gt;

&lt;h2&gt;
  
  
  Componentizing the Map
&lt;/h2&gt;

&lt;p&gt;One of the biggest advantages of using React for your Leaflet maps is the ability to create reusable components. Consider creating a separate component for each map you create, and pass in any necessary props to customize the map's behavior and appearance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Optimizing Performance
&lt;/h2&gt;

&lt;p&gt;To optimize performance, consider using lazy loading to only load the map components when they are needed, and unloading them when they are no longer in use. You can also use &lt;code&gt;React.memo()&lt;/code&gt; to memoize your components and prevent unnecessary re-renders.&lt;/p&gt;

&lt;h2&gt;
  
  
  Avoiding Direct DOM Manipulation
&lt;/h2&gt;

&lt;p&gt;Avoid directly manipulating the DOM with Leaflet code, as this can cause conflicts with React's virtual DOM. Instead, use React's state and props to control the behavior and appearance of the map.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using the React-Leaflet Library
&lt;/h2&gt;

&lt;p&gt;When working with Leaflet maps in a React app, it's recommended to use the react-leaflet library, as it provides a simple and convenient way to integrate Leaflet maps with React. It also handles some of the common issues that can arise when using Leaflet in a React app, such as managing the lifecycle of the map components.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keeping the Map Simple
&lt;/h2&gt;

&lt;p&gt;Finally, when designing your Leaflet maps, remember to keep them simple and easy to use. Avoid cluttering the map with too much information or too many controls, as this can overwhelm the user and make the map difficult to navigate. Instead, focus on providing the key information that the user needs, and use intuitive controls that are easy to understand and use.&lt;/p&gt;

&lt;p&gt;By following these best practices, you can create beautiful and efficient Leaflet maps in your React app that provide a great user experience.&lt;/p&gt;

&lt;h2&gt;
  
  
  Troubleshooting
&lt;/h2&gt;

&lt;p&gt;Even with careful planning and attention to detail, you may run into issues when adding Leaflet maps to your React app. Here are a few common issues and how to troubleshoot them:&lt;/p&gt;

&lt;h3&gt;
  
  
  Map Not Displaying
&lt;/h3&gt;

&lt;p&gt;If your map is not displaying, check the following:&lt;/p&gt;

&lt;p&gt;-Make sure the Leaflet and React-Leaflet libraries are properly installed and imported in your app.&lt;br&gt;
-Check that the container element for your map has a defined width and height.&lt;br&gt;
-Verify that the map component is being rendered properly in your app.&lt;/p&gt;

&lt;h3&gt;
  
  
  Map Not Centering or Zooming
&lt;/h3&gt;

&lt;p&gt;If your map is not centering or zooming correctly, check the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Verify that the map's center and zoom props are being set correctly.&lt;/li&gt;
&lt;li&gt;Check that the center and zoom props are being updated when the user interacts with the map.&lt;/li&gt;
&lt;li&gt;Ensure that any markers or layers on the map are not causing the map to zoom or center incorrectly.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Performance Issues
&lt;/h3&gt;

&lt;p&gt;If your map is causing performance issues, check the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Check that the map is being lazy loaded and unloaded properly to prevent unnecessary rendering.&lt;/li&gt;
&lt;li&gt;Verify that the &lt;code&gt;React.memo()&lt;/code&gt; function is being used to memoize your map components and prevent unnecessary re-renders.&lt;/li&gt;
&lt;li&gt;Ensure that your map is not rendering too many markers or layers at once, as this can cause performance issues.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Interactivity Issues
&lt;/h3&gt;

&lt;p&gt;If you are having issues with interactivity on your map, check the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ensure that any markers or layers on the map are properly registering and responding to user interactions.&lt;/li&gt;
&lt;li&gt;Check that the onClick and other event listener props are being set and updated correctly.&lt;/li&gt;
&lt;li&gt;Verify that the Leaflet library is not interfering with React's event system.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By troubleshooting these common issues, you can ensure that your Leaflet maps are functioning properly and providing a great user experience in your React app.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Congratulations! You have successfully added Leaflet maps to your React app front-end. You should now have a solid understanding of how to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install and set up the Leaflet and React-Leaflet libraries&lt;/li&gt;
&lt;li&gt;Build a map component with custom markers and layers&lt;/li&gt;
&lt;li&gt;Integrate your map component with your React app&lt;/li&gt;
&lt;li&gt;Follow best practices for optimizing performance and user experience&lt;/li&gt;
&lt;li&gt;Troubleshoot common issues that may arise&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By incorporating Leaflet maps into your React app, you can provide an engaging and interactive experience for your users. Whether you are building a location-based app or just want to add some extra functionality to your site, Leaflet maps offer a powerful tool for visualizing data and engaging with your users.&lt;/p&gt;

&lt;p&gt;If you have any questions or comments, feel free to leave them below. Happy mapping!&lt;/p&gt;

&lt;h2&gt;
  
  
  Additional Resources
&lt;/h2&gt;

&lt;p&gt;If you want to learn more about Leaflet maps and how to use them in your React app, here are some additional resources to check out:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://leafletjs.com/index.html"&gt;Leaflet Documentation&lt;/a&gt; - The official documentation for the Leaflet library.&lt;br&gt;
&lt;a href="https://react-leaflet.js.org/docs/start-introduction/"&gt;React-Leaflet Documentation&lt;/a&gt; - The official documentation for the React-Leaflet library.&lt;br&gt;
&lt;a href="https://www.openstreetmap.org/"&gt;OpenStreetMap&lt;/a&gt; - A free, editable map of the world that provides the data used by many Leaflet maps.&lt;br&gt;
&lt;a href="https://leafletjs.com/plugins.html"&gt;Leaflet Plugins&lt;/a&gt; - A collection of plugins and add-ons for the Leaflet library.&lt;br&gt;
&lt;a href="https://github.com/lennardv2/Leaflet.awesome-markers"&gt;Leaflet AwesomeMarkers&lt;/a&gt; - A plugin for adding custom markers to your Leaflet maps.&lt;/p&gt;

&lt;p&gt;By exploring these resources, you can deepen your understanding of Leaflet maps and discover new ways to integrate them into your React app. Whether you are a beginner or an experienced developer, there is always more to learn and explore in the world of Leaflet maps.&lt;/p&gt;

</description>
      <category>react</category>
      <category>flatironschool</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Seeding to Rails from an API</title>
      <dc:creator>jaredsurya</dc:creator>
      <pubDate>Tue, 07 Feb 2023 01:17:06 +0000</pubDate>
      <link>https://dev.to/jaredsurya/seeding-to-rails-from-an-api-2ap7</link>
      <guid>https://dev.to/jaredsurya/seeding-to-rails-from-an-api-2ap7</guid>
      <description>&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;I am currently a student finishing up phase 4 of my cirriculum at Flatiron School. For this phase I had to reflect on what I had learned, and what I could share with you. While making the full-stack web application (React front-end, Rails back-end), I encountered many problems which I solved. I thought I would convey here one of those, and attempt to create a mini walkthrough guide in case you're attempting to do the same thing. &lt;/p&gt;

&lt;p&gt;While I was building my project - a single page application - there were a number of problems that I had to overcome. The unique coding situation that I found myself in whilst planning involved seeding. I had to get a specific quantity of data, which existed on the internet, into my SQL database. I discovered an API which hosted all the relevant info I needed, and I wanted to fetch it using (here-to-fore unknown) code in my rails &lt;code&gt;seeds.rb&lt;/code&gt; file. &lt;/p&gt;

&lt;p&gt;I got my data from &lt;a href="https://superheroapi.com/"&gt;superheroapi.com&lt;/a&gt;. The site had far more info than what I needed, so I had to figure out how to selectively import data via code in my &lt;code&gt;seeds.rb&lt;/code&gt; file. I began searching around and below you will find my discoveries. None of this stuff was easy, but with some crafty deductive logic it all came together into just what my project needs.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Good Stuff
&lt;/h2&gt;

&lt;p&gt;I new I wanted to make a webpage about superheroes and I was glad to find out they had an API for just that. As I sifted through the data, I found out it was quite comprehensive - FULL of info:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wNkQYeOd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yxvmfan5bloe2a7rxnpw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wNkQYeOd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yxvmfan5bloe2a7rxnpw.png" alt="Raw data" width="701" height="1051"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I only wanted a fraction of that (like 5 key-value pairs), so I had to figure out how to selectively take what I needed and store it, through Rails, in my database. This led me to needing to download and use the &lt;code&gt;rest-client&lt;/code&gt; ruby gem, which I'll detail for you below. &lt;/p&gt;

&lt;h3&gt;
  
  
  REST-client
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;rest-client&lt;/code&gt; has been described as &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"A simple HTTP and REST client for Ruby, inspired by the Sinatra microframework style of specifying actions: get, put, post, delete."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;and &lt;a href="https://github.com/rest-client/rest-client"&gt;this Github link&lt;/a&gt; contains most of the information needed to get started using it. As I learned from &lt;a href="https://rubygems.org/gems/rest-client/versions/2.1.0"&gt;rubygems.org&lt;/a&gt;, all you have to do to get started is run the following command in your terminal. Be sure you are in the appropriate directory, such as the parent directory of your rails project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gem install rest-client
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you have installed the gem, navigate to your &lt;code&gt;seeds.rb&lt;/code&gt; file (within your text editor) and at the very top of the file, type &lt;code&gt;require 'rest-client'&lt;/code&gt;. This will enable your file to use the commands from the rest-client library.&lt;/p&gt;

&lt;h3&gt;
  
  
  CODING the logic
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AtCotxvK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a81odulwvv1wt48q8j7l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AtCotxvK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a81odulwvv1wt48q8j7l.png" alt="superhero seed logic" width="800" height="817"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In my &lt;code&gt;heroesdata&lt;/code&gt; method, on line 9 of my code above, I get down to the business of extracting the information from the external API. By using the &lt;code&gt;rest-client&lt;/code&gt; gem, I was easily able to connect with the resource and make use of the information that was delivered. My &lt;code&gt;Hero&lt;/code&gt; table needed to be populated with heroes. In order to do so, I simply made a GET requst to my endpoint. The syntax for this is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RestClient.get(url, headers={})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On line 10 of my code I call &lt;code&gt;rest-client&lt;/code&gt; in this way with a &lt;code&gt;GET&lt;/code&gt; method and pass in the URL. This delivers the appropriate hero I need, and it needs formatting. The hero that's returned here has way more information than what I can use. I used constructive logic to take away just the components I wanted (key, value pairs), piece by piece. I just took what was useful and left the rest. &lt;/p&gt;

&lt;p&gt;To begin with, I parsed the data into a useable &lt;code&gt;hero_array&lt;/code&gt;. Then, I used the nested data to populate a hash which I call &lt;code&gt;final_hero&lt;/code&gt; on line 21. On line 28 I submited that hash and effectively created the first instance of a &lt;code&gt;Hero&lt;/code&gt; on my heroes table. I need more than one hero, so I make sure the code loops through the &lt;code&gt;heroesdata&lt;/code&gt; method many times. I chose to make 35 heros because that fit the needs of my app, but you could conceivably choose any number you want. With adequate &lt;code&gt;Hero&lt;/code&gt; instances created, I worked on my front end (react-based) to display the data for use (pictured below).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CANYmZoF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4xif7cmd9igmvv449km9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CANYmZoF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4xif7cmd9igmvv449km9.png" alt="heroes displayed" width="800" height="532"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Through using &lt;code&gt;rest-api&lt;/code&gt; gem and some crafty reasoning, I was able to reduce the large quantity of information to a hash that is much smaller:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;final_hero = {
    name: hero_array["name"], 
    full_name: full_name, 
    power_level: power_level,
    publisher: hero_array["biography"]["publisher"],
    image: hero_array["image"]["url"]
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With only 5 key-value pairs (now manageable and precise), the app was thus crafted and everything fit nicely.&lt;br&gt;
It was challenging but fun to create each of these unique features. &lt;code&gt;rest-client&lt;/code&gt; was very helpful for when I needed to seed data using an API, and I hope it works for you too. It was relatively easy to figure out, and I know you will find it useful too. I am grateful for what hard work it must have taken to create such a useful ruby gem, &lt;code&gt;rest-api&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Thank you for reading &amp;amp; happy coding!&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>beginners</category>
      <category>flatironschool</category>
      <category>programming</category>
    </item>
    <item>
      <title>Object Inheritance in Ruby</title>
      <dc:creator>jaredsurya</dc:creator>
      <pubDate>Sun, 20 Nov 2022 21:27:00 +0000</pubDate>
      <link>https://dev.to/jaredsurya/object-inheritance-in-ruby-haa</link>
      <guid>https://dev.to/jaredsurya/object-inheritance-in-ruby-haa</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In real life, different categories or groups &lt;br&gt;
(like people, reptiles, buildings, etc.) are related in all sorts of ways. Within a single group, or class, there are many ways things can be classified. For example, the "people" category or class includes garbage men, shop owners, scientists, etc. Each class shares common features because they are all people. Even though they are different, they all have specialized and unique traits too.&lt;/p&gt;

&lt;p&gt;In coding, we know we always want to cut out repetitious sequences from our code. Object inheritance in Ruby allows us to simplify our code and keep repititious 'code smell' down. We see the similarities between related classes and we abstract out the common methods and behaviors into a parent class.&lt;/p&gt;
&lt;h2&gt;
  
  
  Basics of Inheritance
&lt;/h2&gt;

&lt;p&gt;Inheritance is one of the most important features in an object-oriented language.&lt;br&gt;
It is when a class inherits behavior from another class. If a programmer wants to create a new class and there is a class that already includes some of the code that the programmer wants, then they can derive a new class from the existing class. The class that is passing along behavior is called the superclass and the class that inherits it is called the subclass. The use of inheritance allows us to create a family of classes with shared behavior, while still differentiating those classes. Using this system reuses existing code and allows new classes (sub-classes) to need less new code written. &lt;/p&gt;

&lt;p&gt;Implementing class inheritance creates a family of classes with shared behavior and differentiation. Code that would have been used repetitively gets abstracted and simplified. The new child or subclass adopts attributes and behaviors that are already contained in the parent class. (superclass)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key terms in Inheritance:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Super-class: Classes whose characteristics (methods and behaviors) are inheritable are known as "superclass" (aka. base class or parent class).&lt;/li&gt;
&lt;li&gt;Sub-class: The class which is derived from another class is known as a subclass or derived class or child class. They are sometimes written with their own objects and methods in addition to the superclass methods and objects, etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Examples:
&lt;/h2&gt;
&lt;h2&gt;
  
  
  Defining the Superclass:
&lt;/h2&gt;

&lt;p&gt;Below we have written a class called &lt;code&gt;Bear&lt;/code&gt;. It has many methods, all of which can be passed down and available to its children, aka. subclass. The superclass normally provides the bulk of key code content, that which is inheritable by the children (aka. subclasses).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Bear

  attr_accessor :coat_color, :favorite_food

  def initialize(coat_color, favorite_food)
    @coat_color = coat_color
    @favorite_food = favorite_food
  end

  def speak
    "Grrrowlll!"
  end

  def feed
    "om nom nom!"
  end

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

&lt;/div&gt;



&lt;p&gt;Here we see our &lt;code&gt;Bear&lt;/code&gt; super-class. It is initialized with &lt;code&gt;coat_color&lt;/code&gt; and a &lt;code&gt;favorite_food&lt;/code&gt;. Also present are instance methods, such as &lt;code&gt;speak&lt;/code&gt; and &lt;code&gt;feed&lt;/code&gt;. Each of these methods will be available to any children, inheriters of this &lt;code&gt;Bear&lt;/code&gt; super-class.&lt;/p&gt;

&lt;h2&gt;
  
  
  Subclass:
&lt;/h2&gt;

&lt;p&gt;The subclass is the class which has been derived from the super's code and which extends the usability of that code. (i.e. class methods, instance methods, etc.)&lt;br&gt;
In the code block below we see &lt;code&gt;Bear&lt;/code&gt;'s class characteristics being inherited by &lt;code&gt;Panda&lt;/code&gt;. We also see the general syntax for inheriting , which is the &lt;code&gt;&amp;lt;&lt;/code&gt; placed between the sub-class and the super-class. &lt;code&gt;Panda&lt;/code&gt; now inherits all of the methods and behavior of the parent class. It can now use any of the methods found inside of the &lt;code&gt;Bear&lt;/code&gt; class and can even have some Panda-specific ones of its own.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Panda &amp;lt; Bear

  def speak
    "Grrr..."

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

&lt;/div&gt;



&lt;p&gt;Because &lt;code&gt;Panda&lt;/code&gt; is a child of &lt;code&gt;Bear&lt;/code&gt;, all of the methods defined within &lt;code&gt;Bear&lt;/code&gt; are available for &lt;code&gt;Panda&lt;/code&gt; to use. All of the methods of the parent are inherited by the child. For example, &lt;code&gt;Panda.feed&lt;/code&gt; returns &lt;code&gt;"om nom nom!"&lt;/code&gt; Also, a panda could be initialized with  a &lt;code&gt;coat_color&lt;/code&gt; and &lt;code&gt;favorite_food&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Overwriting Inherited Methods
&lt;/h2&gt;

&lt;p&gt;One feature that differs between the parent class and child class here is how in the parent &lt;code&gt;Bear&lt;/code&gt; class the &lt;code&gt;speak&lt;/code&gt; method returns &lt;code&gt;"Grrrowlll!"&lt;/code&gt; and the child &lt;code&gt;Panda&lt;/code&gt; class has it's own instance method called speak which overwrites its parent. When &lt;code&gt;speak&lt;/code&gt; is called on the &lt;code&gt;Panda&lt;/code&gt; class, &lt;code&gt;"Grrr..."&lt;/code&gt; is returned instead of &lt;code&gt;"Grrrowlll!"&lt;/code&gt;. This illustrates how the subclass can overwrite methods of it's superclass.&lt;/p&gt;

&lt;p&gt;Another example of this would be if we had a superclass of &lt;code&gt;Human&lt;/code&gt; the &lt;code&gt;greet&lt;/code&gt; instance method might say &lt;code&gt;"Hello!"&lt;/code&gt; whereas a member of the &lt;code&gt;Cowboy&lt;/code&gt; class might have a &lt;code&gt;greet&lt;/code&gt; instance method overwriting that of it's parent &lt;code&gt;Human&lt;/code&gt; class. The &lt;code&gt;greet&lt;/code&gt; method of the &lt;code&gt;Cowboy&lt;/code&gt; subclass might return &lt;code&gt;"HOWDY!!"&lt;/code&gt; instead of &lt;code&gt;"Hello!"&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Because of ruby's object orientation and subsequent object inheritance, cleaner less repetitive code can be produced. Also, using the principles of inheritance, we can define generic Ruby classes which can have greater reusability. Smaller subclasses result in more detailed behaviors. With object inheritance we can also code multiple, non-repetitive methods, reducing the total amount of code needed, cleaning and optimizing the code that's useful to us.&lt;/p&gt;

</description>
      <category>motivation</category>
    </item>
    <item>
      <title>Client-side Routing on a React-based SPA</title>
      <dc:creator>jaredsurya</dc:creator>
      <pubDate>Wed, 14 Sep 2022 16:51:48 +0000</pubDate>
      <link>https://dev.to/jaredsurya/client-side-routing-on-a-react-based-spa-4kjk</link>
      <guid>https://dev.to/jaredsurya/client-side-routing-on-a-react-based-spa-4kjk</guid>
      <description>&lt;p&gt;&lt;strong&gt;- WHAT IS SPA?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;From &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/SPA"&gt;mdn web docs:&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;An SPA (Single-page application) is a web app implementation that loads only a single web document, and then updates the body content of that single document via JavaScript APIs such as XMLHttpRequest and Fetch when different content is to be shown.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This therefore allows users to use websites without loading whole new pages from the server, which can result in performance gains and a more dynamic experience, with some tradeoff disadvantages such as SEO, more effort required to maintain state, implement navigation, and do meaningful performance monitoring.One helpful feature we can incorportate into  our Single Page Applications is client-side routing. Single-page applications have, by definition, only one HTML document for the entire application, thus they are a perfect candidate for client-side routing. If we choose to use client-side routing to develop our page, all of the routing logic will be handled within Javascript.  Also, the initial page-loading process happens with a single GET request to the backend server. After that, GET requests may be only needed for supplementary data. The bulk of the application will be loaded and the client-side routing will take control of switching which components are shown, how, and when.  Routing consists of changing what the client is receiving in the web browser based on the endpoint of a URL. Not having to send a GET request on every routing call means that pages using client-side routing methods will render faster. As one of the essential aspects of single-page applications and as React doesn’t come with a routing solution, React developers must integrate third-party libraries to implement routing into their applications. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;- HOW CLIENT-SIDE ROUTING WORKS IN REACT:&lt;/strong&gt;&lt;br&gt;
The general difference between client-side routing and server-side rendering is in which part of the website is the routing/rendering happening. The client-side would have the application programmatically adjust what the user is seeing based on logic in the browser that is affecting the user - experience. With the other, server-side routing, the user makes requests to the server every time there is to be a change to the app screen. With react, client-side routing is preferred. React receives a user request and programmatically renders the appropriate information on the DOM based on its component structure. Client-side routing in React helps to maintain the seamless user experience that a typical single-page application can promise. This may be achieved through an external React library called React Router. React Router uses dynamic routing to ensure that routing is achieved as it is requested by the user. Using React Router means that all the required components are also rendered without any flashes of white screen or page reload. All of this client-side routing produces speedy webpages and a seamless user experience. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;- HOW REACT ROUTER CAN AID IN CLIENT-SIDE ROUTING:&lt;/strong&gt;&lt;br&gt;
In the following notes, I will briefly elaborate on some of the the basics of how React Router works. &lt;a href="https://reactrouter.com/en/main/getting-started/installation"&gt;For steps to install React Router, click here.&lt;/a&gt; Once React Router has been installed, we would import BrowserRouter and wrap the entire App component in it to render it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import ReactDOM from "react-dom/client";
import { BrowserRouter } from "react-router-dom";
import App from "./App";

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

&lt;/div&gt;



&lt;p&gt;Within App.js, we import 'Link' and add some global navigation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Link } from "react-router-dom";

export default function App() {
  return (
    &amp;lt;div&amp;gt;
      &amp;lt;h1&amp;gt;Bookkeeper&amp;lt;/h1&amp;gt;
      &amp;lt;nav&amp;gt;
        &amp;lt;Link to="/invoices"&amp;gt;Invoices&amp;lt;/Link&amp;gt; |{" "}
        &amp;lt;Link to="/expenses"&amp;gt;Expenses&amp;lt;/Link&amp;gt;
      &amp;lt;/nav&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At this point there aren't any routes that render when the URL changes yet, but Link is changing the URL without causing a full page reload.👍&lt;/p&gt;

&lt;p&gt;Now, we'll render some new components to be routed to:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Expenses:&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;export default function Expenses() {
  return (
    &amp;lt;main style={{ padding: "1rem 0" }}&amp;gt;
      &amp;lt;h2&amp;gt;Expenses&amp;lt;/h2&amp;gt;
    &amp;lt;/main&amp;gt;
  );
}

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Invoices:&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;export default function Invoices() {
  return (
    &amp;lt;main style={{ padding: "1rem 0" }}&amp;gt;
      &amp;lt;h2&amp;gt;Invoices&amp;lt;/h2&amp;gt;
    &amp;lt;/main&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, inside of Index.js we'll create our first route config. By setting the path for each element we effectively tell the DOM what component has to be loaded if the specific URL path is chosen. We'll make it so that at "/" it renders  and at "/invoices" it renders :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import ReactDOM from "react-dom/client";
import {
  BrowserRouter,
  Routes,
  Route,
} from "react-router-dom";
import App from "./App";
import Expenses from "./routes/expenses";
import Invoices from "./routes/invoices";

const root = ReactDOM.createRoot(
  document.getElementById("root")
);
root.render(
  &amp;lt;BrowserRouter&amp;gt;
    &amp;lt;Routes&amp;gt;
      &amp;lt;Route path="/" element={&amp;lt;App /&amp;gt;} /&amp;gt;
      &amp;lt;Route path="expenses" element={&amp;lt;Expenses /&amp;gt;} /&amp;gt;
      &amp;lt;Route path="invoices" element={&amp;lt;Invoices /&amp;gt;} /&amp;gt;
    &amp;lt;/Routes&amp;gt;
  &amp;lt;/BrowserRouter&amp;gt;
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, we import Route in order to make each url path, and Routes as a container for them all. &lt;/p&gt;

&lt;p&gt;The next thing we will have to do is create a Link for the client to click on and navigate the page:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Link, Outlet } from "react-router-dom";
import { getInvoices } from "../data";

export default function Invoices() {
  let invoices = getInvoices();
  return (
    &amp;lt;div style={{ display: "flex" }}&amp;gt;
      &amp;lt;nav
        style={{
          borderRight: "solid 1px",
          padding: "1rem",
        }}
      &amp;gt;
        {invoices.map((invoice) =&amp;gt; (
          &amp;lt;Link
            style={{ display: "block", margin: "1rem 0" }}
            to={`/invoices/${invoice.number}`}
            key={invoice.number}
          &amp;gt;
            {invoice.name}
          &amp;lt;/Link&amp;gt;
        ))}
      &amp;lt;/nav&amp;gt;
      &amp;lt;Outlet /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Above we see the Link components being made as the invoices array is mapped through, producing one Link of appropriate parameters per invoice. When the Link is clicked by someone navigating the website, the React Router would render that component. The URL would also show that we were viewing that page. &lt;/p&gt;

&lt;p&gt;You can demo a working version of this app &lt;a href="https://stackblitz.com/edit/github-agqlf5?file=src%2FApp.jsx"&gt;here.&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;For a somewhat broader overview of what's possible with React Router, as well as some more how-to, visit &lt;a href="https://reactrouter.com/en/v6.3.0/getting-started/overview"&gt;this page.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;React Router and other libraries like it are so brilliant because they take complex programmatic issues and have worked through them to enable a solution which makes many web pages run much faster. Client-side routing is hugely impactful as a means of navigating many webpages. The webpage user gets a streamlined experience in a quicker way than ever before. &lt;br&gt;
To go even more in depth to the concepts which make React Router run, &lt;a href="https://reactrouter.com/en/main/start/concepts"&gt;click here!&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Client-side routing can provide a great performance benefit if your application consists mainly of a static page or if it's a landing page for your company. And, you're using a backend-less application, it can speed up your single-page application and provide seamless user experience. Since conventional server-side rendering can out-perform client-side routing in various situations, it's still important to understand the needs of your application. With this knowledge, you can decide whether to use client-side routing, server-side routing, or a combination of both.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>react</category>
      <category>flatiron</category>
      <category>routing</category>
    </item>
    <item>
      <title>The Almighty CRUD</title>
      <dc:creator>jaredsurya</dc:creator>
      <pubDate>Mon, 05 Sep 2022 19:27:40 +0000</pubDate>
      <link>https://dev.to/jaredsurya/the-almighty-crud-32k2</link>
      <guid>https://dev.to/jaredsurya/the-almighty-crud-32k2</guid>
      <description>&lt;p&gt;Since I've completed my second phase of schoolwork at &lt;a href="//flatironschool.com"&gt;Flatiron School&lt;/a&gt;, I thought I should re-visit and explore an important concept which I've been using during this phase. This phase at Flatiron School we predominately focused on the React programming language. During these studies, CRUD and its methods was also a readily utilized topic. It's also one which deserves more exploring. Below I will elaborate on what CRUD is, and how we've interacted with it within almost every React lab we did this phase. &lt;/p&gt;

&lt;p&gt;An important concept in the web developers' world is &lt;strong&gt;CRUD&lt;/strong&gt;, which stands for &lt;strong&gt;C&lt;/strong&gt;reate, &lt;strong&gt;R&lt;/strong&gt;ead, &lt;strong&gt;U&lt;/strong&gt;pdate and &lt;strong&gt;D&lt;/strong&gt;elete. Each letter in this acronym is an important way of viewing, searching, or changing information using computer-based forms and reports. A web developer would want to pay attention to &lt;strong&gt;CRUD&lt;/strong&gt; and &lt;strong&gt;REST&lt;/strong&gt; while going to make network requests via an API. In this phase at Flatiron we used many principles found in CRUD to make &lt;strong&gt;REST&lt;/strong&gt;ful API requests to both local and remote servers. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;REST&lt;/strong&gt; is an acronym for &lt;strong&gt;RE&lt;/strong&gt;presentational &lt;strong&gt;S&lt;/strong&gt;tate &lt;strong&gt;T&lt;/strong&gt;ransfer and an architectural style for distributed hypermedia systems. It was first presented in in 2000 during Roy Fielding's famous dissertation. REST APIs communicate via HTTP requests to perform standard database functions like creating, reading, updating, and deleting records (CRUD) within a resource. For example, a REST API would use a GET request to retrieve a record, a POST request to create one, a PUT request to update a record, and a DELETE request to delete one.&lt;/p&gt;

&lt;p&gt;For the acronym, &lt;strong&gt;C.R.U.D.&lt;/strong&gt;, we can elaborate a little more about what each letter means. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C&lt;/strong&gt; is for Create. The create function allows users to create a new record in the database. In the SQL relational database application, the Create function is called INSERT. SQL (Structured Query Language) is a programming language used to communicate with data stored in a relational database management system. SQL syntax is similar to the English language, which makes it relatively easy to write, read, and interpret. When making RESTful API requests, the name of the request is POST. It creates a new insertion in the database info. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;R&lt;/strong&gt; is for Read. The read function is similar to a search function. It allows users to search and retrieve specific records in the database and read their values. Users may be able to find desired records using keywords, or by filtering the data based on customized criteria. When making API requests, the type of request that corresponds to 'Read' is 'GET.' &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;U&lt;/strong&gt; is for Update. The update function is used to modify existing records that exist in the database. To fully change a record, users may have to modify information in multiple fields. In RESTful API methods, the Update of CRUD corresponds to PATCH and PUT. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;D&lt;/strong&gt; is for Delete. The delete function allows users to remove records from a database that are no longer needed. In a RESTful API scenario, the method we use to Delete the records from the server is DELETE. Fancy that!&lt;/p&gt;

&lt;p&gt;As I worked through the second phase of Software Engineering cirriculum at Flatiron School, CRUD was a topic that students needed to know of for many reasons. There are many required operations in labs which can use the RESTful CRUD methods. In lab work, when we would update state in our react labs we had to make a corresponding fetch request to persist that change to an API. API means Application Programming Interface, which is a software intermediary that allows two applications to talk to each other. For the labs, we were trying to get our React application, to carry out CRUD requests that would alter data both remotely, and locally from our json-server.&lt;/p&gt;

&lt;p&gt;To persist our stateful changes to the 'backend' server, we made fetch requests for each type, &lt;strong&gt;c, r, u,&lt;/strong&gt; and &lt;strong&gt;d.&lt;/strong&gt; Below are some examples of how CRUD was used in our lessons for Flatiron School.&lt;/p&gt;

&lt;p&gt;The following POST request &lt;strong&gt;C&lt;/strong&gt;reates new information to be written to the server: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dkVwu0B9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nx1g86q7ruxmshmvgn3p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dkVwu0B9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nx1g86q7ruxmshmvgn3p.png" alt="CREATE" width="493" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the following GET request we used, information is &lt;strong&gt;R&lt;/strong&gt;ead from the server:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WEctSueN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bottof7cznkzrgii8mdi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WEctSueN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bottof7cznkzrgii8mdi.png" alt="READ" width="718" height="279"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The following PATCH request &lt;strong&gt;U&lt;/strong&gt;pdates information in the server:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MdoefJCG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0e9lbdbkldqvpumg9y4a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MdoefJCG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0e9lbdbkldqvpumg9y4a.png" alt="UPDATE" width="566" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And, the following DELETE request &lt;strong&gt;D&lt;/strong&gt;eletes information from the server:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XAzCKYgh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4aaxd4setzt4jeey1plu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XAzCKYgh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4aaxd4setzt4jeey1plu.png" alt="DELETE" width="543" height="188"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each type of API request we made had a different mode, each corresponding to one of the &lt;strong&gt;CRUD&lt;/strong&gt; methods. By using these methods we were readily able to successfully Create, Read, Update, and Delete information from our server, and persist changes. &lt;/p&gt;

&lt;p&gt;Betwixt all these requests back and forth from our json-server, there was much interaction with the React programming language, which kept the program's internal state up to date with all the information the server had stored. &lt;/p&gt;

&lt;p&gt;CRUD really was an important part of my labs and development of knowledge during this phase at Flatiron. Without the CRUD methods, and their use, much of the programming involved with React would have been inoperable. All of this and more was a big part of what I had learned in Phase 2 at &lt;a href="https://flatironschool.com/"&gt;Flatiron School.&lt;/a&gt;&lt;/p&gt;

</description>
      <category>crud</category>
      <category>flatironschool</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>A Simple Overview of JavaScript Object Destructuring</title>
      <dc:creator>jaredsurya</dc:creator>
      <pubDate>Thu, 26 May 2022 18:42:42 +0000</pubDate>
      <link>https://dev.to/jaredsurya/a-simple-overview-of-object-destructuring-in-javascript-28g8</link>
      <guid>https://dev.to/jaredsurya/a-simple-overview-of-object-destructuring-in-javascript-28g8</guid>
      <description>&lt;p&gt;As I have just finished my first phase of study with Flatiron School, it occurred to me that I should display a portion of what I learned for others to benefit from. &lt;/p&gt;

&lt;p&gt;For this, I have chosen &lt;strong&gt;object destructuring&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Summary:&lt;/strong&gt; Here we'll explore some JavaScript object destructuring methods that assign properties of an object to individual variables.&lt;/p&gt;

&lt;p&gt;Let's say we have an object containing someone's elemental makeup reading, taken by an oriental philosopher. &lt;a href="https://www.nationsonline.org/oneworld/Chinese_Customs/five_elements.htm"&gt;Follow this link to learn more.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;let johnsElementalMakeup = {&lt;br&gt;
  wood: "13%",&lt;br&gt;
  fire: "17%",&lt;br&gt;
  earth: "23%",&lt;br&gt;
  metal: "22%",&lt;br&gt;
  water: "25%"&lt;br&gt;
};&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---yOX-T8Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jmnw0ndit3h5966erstd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---yOX-T8Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jmnw0ndit3h5966erstd.png" alt="Basic Object" width="364" height="228"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The traditional way (before ES6) to assign properties of the johnsElementalMakeup object to variables was the following:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;let wood = elementalMakeup.wood;&lt;br&gt;
let earth = elementalMakeup.earth;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Z7hFfFOZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ax4sckf11o8py21u939j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z7hFfFOZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ax4sckf11o8py21u939j.png" alt="Destructuring" width="439" height="74"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since ES6, we can now use the following:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;let { wood: wo, fire: f, earth: e, metal: m, water: wa } = johnsElementalMakeup&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GUBLzGhW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q4qlt59g91ks98w4hn0s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GUBLzGhW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q4qlt59g91ks98w4hn0s.png" alt="Image description" width="800" height="43"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, the variables of wo, f , e, m , and wa would be assigned to the values of wood, fire, earth, metal and water, respectively. &lt;/p&gt;

&lt;p&gt;The basic syntax for this is:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;let { key1: variable1, key2: variable2 } = object;&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F-8LAStu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gfh83ausvmnigo17r0c6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F-8LAStu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gfh83ausvmnigo17r0c6.png" alt="Image description" width="638" height="38"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The identifier before the colon (:) is the key/property of the object and the identifier after the colon is the variable.&lt;/p&gt;

&lt;p&gt;If the variables should have the same names as the keys of the object, we can simplify as shown:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;let { wood, fire, earth, metal, water } = johnsElementalMakeup&lt;br&gt;
console.log(wood, fire, earth) // "13%", "17%", "23%"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--C7Hzd1ip--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c38hjt3j1trpppwghpfz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--C7Hzd1ip--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c38hjt3j1trpppwghpfz.png" alt="Image description" width="786" height="68"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each of the key names within johnsElementalMakeup are now variable names which are assigned to the respective percentage values. &lt;/p&gt;

&lt;p&gt;Adding in a key name that doesn't exist within the object would result in that variable being assigned "undefined".&lt;/p&gt;

&lt;p&gt;For more, including how to destructure nested arrays, I suggest you check out the documentation at MDN: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment"&gt;Here.&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>flatiron</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Timing of Things</title>
      <dc:creator>jaredsurya</dc:creator>
      <pubDate>Tue, 22 Mar 2022 20:21:34 +0000</pubDate>
      <link>https://dev.to/jaredsurya/timing-of-things-1o5i</link>
      <guid>https://dev.to/jaredsurya/timing-of-things-1o5i</guid>
      <description>&lt;p&gt;The journey so far has taught me a lot. Some of my latest difficulties have come in form of falling behind in my teachings. I'm more or less up to date now, but the vacation I went on had set me back a bit. I need to be more diligent so that I can finish on time or ahead of schedule. &lt;/p&gt;

</description>
      <category>flatiron</category>
    </item>
    <item>
      <title>Getting Stuck</title>
      <dc:creator>jaredsurya</dc:creator>
      <pubDate>Tue, 08 Mar 2022 16:02:26 +0000</pubDate>
      <link>https://dev.to/jaredsurya/getting-stuck-ic8</link>
      <guid>https://dev.to/jaredsurya/getting-stuck-ic8</guid>
      <description>&lt;p&gt;This stuff certainly has its ups and downs. I'm learning to use .find() in javascript and feeling pretty stuck here. &lt;/p&gt;

</description>
      <category>flatiron</category>
      <category>javascript</category>
      <category>learning</category>
    </item>
    <item>
      <title>First Post!</title>
      <dc:creator>jaredsurya</dc:creator>
      <pubDate>Tue, 22 Feb 2022 20:21:19 +0000</pubDate>
      <link>https://dev.to/jaredsurya/first-post-1415</link>
      <guid>https://dev.to/jaredsurya/first-post-1415</guid>
      <description>&lt;p&gt;Today I am posting about my time with Flatiron School so far. &lt;/p&gt;

&lt;p&gt;I really enjoy the way the online curriculum is laid out. In addition to making content easy to understand, they have technical coaches standing by to help when necessary. The group of students I am with seems very kind and I'm hoping we can help each other through this first phase of our schooling. &lt;/p&gt;

</description>
      <category>beginners</category>
    </item>
  </channel>
</rss>
