<?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: CalebMcCoy04</title>
    <description>The latest articles on Forem by CalebMcCoy04 (@calebmccoy04).</description>
    <link>https://forem.com/calebmccoy04</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%2F971021%2Fac985cc2-914e-4eda-a987-4c25845acfa3.png</url>
      <title>Forem: CalebMcCoy04</title>
      <link>https://forem.com/calebmccoy04</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/calebmccoy04"/>
    <language>en</language>
    <item>
      <title>Modal Box</title>
      <dc:creator>CalebMcCoy04</dc:creator>
      <pubDate>Thu, 05 Jan 2023 17:31:49 +0000</pubDate>
      <link>https://forem.com/calebmccoy04/modal-box-19l</link>
      <guid>https://forem.com/calebmccoy04/modal-box-19l</guid>
      <description>&lt;p&gt;A modal box is a dialog box or window that appears on top of the current page, and requires the user to interact with it before they can return to the underlying page. Modal boxes are often used to display important content or to prompt the user for a specific action, such as filling out a form or making a decision.&lt;/p&gt;

&lt;p&gt;There are several types of modal boxes, including:&lt;/p&gt;

&lt;p&gt;Alerts: These are modal boxes that display a message and require the user to click a button to acknowledge the message and close the box.&lt;/p&gt;

&lt;p&gt;Confirmations: These are modal boxes that prompt the user to confirm or cancel an action.&lt;/p&gt;

&lt;p&gt;Prompts: These are modal boxes that request input from the user, such as a name or email address.&lt;/p&gt;

&lt;p&gt;Modal boxes can be triggered by various events, such as clicking a button or link, hovering over an element, or loading a page. They can also be triggered programmatically using JavaScript.&lt;/p&gt;

&lt;p&gt;Here is just an example in react for its use:&lt;br&gt;
import React, { useState } from 'react';&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';

function ModalExample() {
  // State to track whether the modal is open or closed
  const [modalOpen, setModalOpen] = useState(false);

  return (
    &amp;lt;&amp;gt;
      {/* Button that triggers the modal */}
      &amp;lt;button onClick={() =&amp;gt; setModalOpen(true)}&amp;gt;Open Modal&amp;lt;/button&amp;gt;

      {/* Modal component */}
      {modalOpen &amp;amp;&amp;amp; (
        &amp;lt;div className="modal"&amp;gt;
          &amp;lt;div className="modal-content"&amp;gt;
            &amp;lt;button onClick={() =&amp;gt; setModalOpen(false)}&amp;gt;Close&amp;lt;/button&amp;gt;
            &amp;lt;p&amp;gt;Modal content goes here&amp;lt;/p&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
      )}
    &amp;lt;/&amp;gt;
  );
}

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

&lt;/div&gt;



&lt;p&gt;This code will create a modal box with a close button and some content. The modal is hidden by default, and is displayed when the user clicks the "Open Modal" button. The user can close the modal by clicking the close button.&lt;/p&gt;

&lt;p&gt;Modal boxes are a useful tool for web developers because they allow them to display important content or prompts to the user without requiring a new page load. This helps to improve the user experience and keep the user on the current page.&lt;/p&gt;

&lt;p&gt;That's a brief overview of modal boxes! I hope it was helpful.&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>all the CRUD</title>
      <dc:creator>CalebMcCoy04</dc:creator>
      <pubDate>Tue, 13 Dec 2022 17:09:59 +0000</pubDate>
      <link>https://forem.com/calebmccoy04/all-the-crud-319j</link>
      <guid>https://forem.com/calebmccoy04/all-the-crud-319j</guid>
      <description>&lt;p&gt;CRUD is a common acronym in the world of programming. It stands for Create, Read, Update, and Delete, and it refers to the four basic operations that can be performed on a database.&lt;/p&gt;

&lt;p&gt;In this post, we'll take a look at how to implement CRUD using Ruby on Rails and JSON. Here's an example of a controller that performs CRUD operations on a Product model:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Create a new record in the database
def create
  product = Product.new(product_params)

  if product.save
    render json: product, status: :created
  else
    render json: product.errors, status: :unprocessable_entity
  end
end

# Read a record from the database
def show
  product = Product.find(params[:id])

  render json: product
end

# Update an existing record in the database
def update
  product = Product.find(params[:id])

  if product.update(product_params)
    render json: product
  else
    render json: product.errors, status: :unprocessable_entity
  end
end

# Delete a record from the database
def destroy
  product = Product.find(params[:id])
  product.destroy

  head :no_content
end

private

# Strong parameters
def product_params
  params.require(:product).permit(:name, :price, :description)
end

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

&lt;/div&gt;



&lt;p&gt;In this example, the controller methods return JSON data instead of rendering views. JSON (JavaScript Object Notation) is a lightweight data interchange format that is often used to exchange data between web applications and servers. In this case, the controller methods return a JSON representation of the Product object that is being created, retrieved, updated, or deleted. This allows a client application to access the data and use it however it needs to.&lt;/p&gt;

&lt;p&gt;That's it! You can use this simple example as a starting point for implementing CRUD in your own Rails applications.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>ruby</category>
    </item>
    <item>
      <title>Switch vs Routes in React V5 vs. V6</title>
      <dc:creator>CalebMcCoy04</dc:creator>
      <pubDate>Wed, 07 Dec 2022 15:46:14 +0000</pubDate>
      <link>https://forem.com/calebmccoy04/switch-vs-routes-in-react-v5-vs-v6-2be</link>
      <guid>https://forem.com/calebmccoy04/switch-vs-routes-in-react-v5-vs-v6-2be</guid>
      <description>&lt;p&gt;Hello today I am going to be talking about using Switch vs. Routes hook in react and the basic setup. to get started first run this command in your terminal to install the react router.&lt;br&gt;
&lt;em&gt;npm install react-router-dom&lt;/em&gt;&lt;br&gt;
add @5 at the end to install version 5&lt;/p&gt;

&lt;p&gt;Switch and Routes is just a special version of the  tag &lt;br&gt;
Next lets go over what the syntax will look like &lt;strong&gt;this will be version dependent!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;first we will show the version 6&lt;br&gt;
&lt;/p&gt;

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

function App(){
  return (
    &amp;lt;Routes&amp;gt;
      &amp;lt;Route path="/" element={Component/&amp;gt;}/&amp;gt;
    &amp;lt;Routes&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;now we will show version 5&lt;br&gt;
&lt;/p&gt;

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

function App(){
  return (
    &amp;lt;Switch&amp;gt;
      &amp;lt;Route exact path="/"&amp;gt;
        &amp;lt;Component/&amp;gt;
      &amp;lt;/Route
    &amp;lt;Switch&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;side note exact sometimes cause an error so try deleting it if this happens.&lt;/p&gt;

&lt;p&gt;sources:&lt;br&gt;
&lt;a href="https://reactrouter.com/en/main/start/overview"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>react</category>
    </item>
    <item>
      <title>Hoisting</title>
      <dc:creator>CalebMcCoy04</dc:creator>
      <pubDate>Tue, 22 Nov 2022 16:11:42 +0000</pubDate>
      <link>https://forem.com/calebmccoy04/hoisting-4l5g</link>
      <guid>https://forem.com/calebmccoy04/hoisting-4l5g</guid>
      <description>&lt;p&gt;Hello, Just wanted to chat about a topic that confused me in the beginning, hoisting.&lt;br&gt;
Hoisting refers to setting variables, functions, or classes to the top level of their scope.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const hoistedVariable = 1
//this is hoisted 
function something(){
return hoistedVAriable + 1
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;const and let both can be hoisted but are not initialized. &lt;/p&gt;

&lt;p&gt;Where as if we had some variable declared within a function it would not be hoisted.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function Something(){
const notHoisted = 2
// not hoisted
return notHoisted + 4
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the above examples show hoisted vs not hoisted. &lt;br&gt;
there is some interesting stuff with var but for me best practice its not to use var so that wont be covered here. &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Functions</title>
      <dc:creator>CalebMcCoy04</dc:creator>
      <pubDate>Sat, 12 Nov 2022 02:51:47 +0000</pubDate>
      <link>https://forem.com/calebmccoy04/functions-o88</link>
      <guid>https://forem.com/calebmccoy04/functions-o88</guid>
      <description>&lt;p&gt;Hello, today I just want to chat about functions and how useful they are. Functions are tool that we can use that make our code more dynamic and are like the a swiss army knife of coding. Functions are  fun to set up and reusing them is satisfying especially when you can just slot them in and everything flows. Functions are very good tool to learn and understand. Here is the function syntax to get you started: &lt;br&gt;
function someFunction(parameter){ return something }&lt;br&gt;
Function even have their own scope and you can write code that only deploys when that function is invoked. This tool can save you a ton of time when coding if you know that you will be reusing that code. have to pull something from the DOM write a function for that process! Functions also return something so there is an input and an output.  Over all just want to gush about functions for a bit since they are so neat and handy!&lt;/p&gt;

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