<?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: elifrie</title>
    <description>The latest articles on DEV Community by elifrie (@elifrie).</description>
    <link>https://dev.to/elifrie</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%2F1062469%2Ff78b5207-e32f-46aa-93f7-e8def25fadab.png</url>
      <title>DEV Community: elifrie</title>
      <link>https://dev.to/elifrie</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/elifrie"/>
    <language>en</language>
    <item>
      <title>Edge Case: What to do when you need to push data to front-end with formatting unaffected. The Pre tag</title>
      <dc:creator>elifrie</dc:creator>
      <pubDate>Tue, 18 Jul 2023 21:01:53 +0000</pubDate>
      <link>https://dev.to/elifrie/edge-case-what-to-do-when-you-need-to-push-data-to-front-end-with-formatting-unaffected-the-pre-tag-2hh4</link>
      <guid>https://dev.to/elifrie/edge-case-what-to-do-when-you-need-to-push-data-to-front-end-with-formatting-unaffected-the-pre-tag-2hh4</guid>
      <description>&lt;p&gt;When I was working on a personal project I ran into an edge case that required me to output my information on the front-end the same way it was coming in on the backend. &lt;/p&gt;

&lt;p&gt;There were no good resources to display information as such, but after some digging I discovered the (&lt;code&gt;pre&lt;/code&gt;) tag. &lt;/p&gt;

&lt;p&gt;In React, the (&lt;code&gt;pre&lt;/code&gt;) tag is used to render preformatted text, preserving any whitespace and line breaks within it. To use it, simply create a component or element in your JSX code and wrap the desired preformatted text with the (&lt;code&gt;pre&lt;/code&gt;) tags. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function PreformattedText() {
  return (
    &amp;lt;pre&amp;gt;
      This is an example of preformatted text.
      It will preserve all whitespace and line breaks.
      Useful for displaying code snippets or structured data.
    &amp;lt;/pre&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the component is rendered, the text inside the (&lt;code&gt;pre&lt;/code&gt;) tags will be displayed exactly as it is written in the code, maintaining indentation and formatting. This is particularly helpful when presenting code blocks or any content that requires precise visual representation.&lt;/p&gt;

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

</description>
    </item>
    <item>
      <title>Validators in Flask</title>
      <dc:creator>elifrie</dc:creator>
      <pubDate>Fri, 30 Jun 2023 15:31:23 +0000</pubDate>
      <link>https://dev.to/elifrie/validators-in-flask-5fo1</link>
      <guid>https://dev.to/elifrie/validators-in-flask-5fo1</guid>
      <description>&lt;p&gt;As you begin to create and manage databases it's important to keep in mind that the type of data you are allowing users to input can have large effects on your databases. Validators are used to do just that; maintain the integrity of the data flowing into your databases.&lt;/p&gt;

&lt;p&gt;You must imagine every possible edge case for how a user will interact with your webpage and then utilize validators to protect against those cases.&lt;/p&gt;

&lt;p&gt;Using validators is generally very intuitive and basic. &lt;/p&gt;

&lt;p&gt;Within your models and class definitions on the back-end you can define validators as so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class User(db.Model, SerializerMixin):
   __tablename__ = 'users'

   ##here all your relationships will lie##


   ###below you are defining what variable you will be validating.##
   @validates('username'):
   ##creating a validation##
   def validate_username(self, key, value):
      if not value:
           raise ValueError('Please enter a username')
   ##forcing a user to enter a value for their username to proceed, otherwise they will see a value error##
      return value
   ##returning the value if a username is provided by the user##
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Above is an example of how you would do a simple validation for one variable. You'll notice I passed through 'value' rather than 'username' and checked against value. The reason for that is so you can check multiple variables if they require the same validation. The example below is how you would force a user to input a value for both username and email.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class User(db.Model, SerializerMixin):
   __tablename__ = 'users'

   ##here all your relationships will lie##

   @validates('username', 'email'):
   def validate_username(self, key, value):
      if not value:
           raise ValueError('Please enter a username')
      return value
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At the end of the day validating isn't too daunting and it's something that is important to implement upfront to save you time on the &lt;em&gt;back-end&lt;/em&gt; haha ;).&lt;/p&gt;

</description>
      <category>flask</category>
      <category>backend</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Raising Exception Explained</title>
      <dc:creator>elifrie</dc:creator>
      <pubDate>Thu, 08 Jun 2023 18:01:00 +0000</pubDate>
      <link>https://dev.to/elifrie/raising-exception-explained-23ki</link>
      <guid>https://dev.to/elifrie/raising-exception-explained-23ki</guid>
      <description>&lt;p&gt;Hey everyone! I'm back with another beginner's explanation, but this time in a new language. &lt;/p&gt;

&lt;p&gt;For the past few weeks I've been sinking my teeth into python and learning the basic motions. Working through errors is something that every software engineer of every level has to deal with. In order to continue to run your program regardless of certain errors coming up it is important to 'Raise Exceptions'. &lt;/p&gt;

&lt;p&gt;Raising an exception allows you to set a default response if your program runs into some type of error. This way your entire program won't crash due to a small syntax error and based on your error message you may be able to tell where your program ran into an error.&lt;/p&gt;

&lt;p&gt;Now let's see an example. &lt;/p&gt;

&lt;p&gt;Let's say you are writing a plethora of if statements to handle many conditions and situations. Your program is crashing but you're not sure where you're running into issues. Is it when you're checking if variable &lt;code&gt;x&lt;/code&gt; is a string? Is it when you're making sure that the price is between set parameters? By raising an exception for each condition you can specify what message to return in the event of failure. Then handling errors without breaking code is much more simple.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if isinstance(x, str):
   print("X is a string!")
else:
   raise Exception("Please enter a valid string!")

##Input: 2
  Output: Please enter a valid string!

if 1 &amp;lt;= price &amp;lt;= 100
   print("The price is right!")
else:
   raise Exception("Please enter a number between 1 and 100")

##Input: 2
  Output: The price is right!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without raising an exception the program would break on the user, but now it will return an error to guide them in the correct direction and provide information to guard against future errors.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>python</category>
    </item>
    <item>
      <title>Basic Understanding of useState in React</title>
      <dc:creator>elifrie</dc:creator>
      <pubDate>Tue, 16 May 2023 15:20:50 +0000</pubDate>
      <link>https://dev.to/elifrie/basic-understanding-of-usestate-in-react-214</link>
      <guid>https://dev.to/elifrie/basic-understanding-of-usestate-in-react-214</guid>
      <description>&lt;p&gt;Hello and welcome to the second leg of my journey through introductory coding! As you begin to grasp the basic concepts of React there are a few nuances that you must understand. One of these is the react hook useState. &lt;/p&gt;

&lt;h2&gt;
  
  
  What is useState and when do I need it?
&lt;/h2&gt;

&lt;p&gt;useState leverages array destructuring to declare a state variable. A state variable is used when you have values that need to change based on an interaction (ex. forms with value changes, search bars, click events that change, etc.)&lt;/p&gt;

&lt;p&gt;First thing is first; you must &lt;em&gt;call&lt;/em&gt; useState at the top of each component where you plan to utilize it. You can do this by:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;import {useState} from 'react';&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then you must declare the state variable as well as its initial state. The initial state will vary based on what kind of value the variable will hold. If the result is boolean then you should set the initial state to a boolean, if it is meant to return an object then you should structure the object as a default, etc. &lt;/p&gt;

&lt;p&gt;Let's say we want to use a state variable for an input that is an age. Thus, we would want the initial state to be a &lt;em&gt;number&lt;/em&gt;. The basic syntax and the syntax for our purposes is as follows:&lt;/p&gt;

&lt;p&gt;Basic:&lt;br&gt;
&lt;code&gt;const [something, setSomething] = useState(initialState)&lt;/code&gt;&lt;br&gt;
Ours:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function myComponent() {

   const [age, setAge] = useState(25);
   const [name, setName] = useState('Eli')}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The return value will be an array that has two items; the current state of this item (set to the initial state that I defined) and the &lt;em&gt;set&lt;/em&gt; value that lets me change the value based an interaction.&lt;/p&gt;

&lt;p&gt;To update our value we need to call the function and update the state:&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 () {

   setAge(54)}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;React will now store my next state, render my component again with age as 54, then update my UI.&lt;/p&gt;

&lt;p&gt;I hope this was helpful in gaining a very basic understanding of useState in react. Happy coding!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Explaining event.target</title>
      <dc:creator>elifrie</dc:creator>
      <pubDate>Tue, 25 Apr 2023 15:39:04 +0000</pubDate>
      <link>https://dev.to/elifrie/explaining-eventtarget-d9n</link>
      <guid>https://dev.to/elifrie/explaining-eventtarget-d9n</guid>
      <description>&lt;p&gt;My name is Eli Friedlander. As I begin my software engineering journey there are many topics that I could dig deeper into. Throughout the past weeks I have often been confused about the syntax, usage, functionality, etc. of different nuances in javascript, HTML, and CSS. I’ve found solace in blog posts such as this. I hope this can help clear any confusion you may have surrounding the use of “event.target”.&lt;/p&gt;

&lt;p&gt;In short - event.target is a property of an event object that &lt;em&gt;targets&lt;/em&gt; the specific element that triggers the event. This becomes useful when you are looking to return the &lt;em&gt;value&lt;/em&gt; of the element that triggered the referenced event. &lt;/p&gt;

&lt;h2&gt;
  
  
  When to use:
&lt;/h2&gt;

&lt;p&gt;As mentioned above - the target property is used to retrieve any attribute or property of the event it is attached to. Let’s say we have an event listener for an input box like below:&lt;/p&gt;

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

&lt;p&gt;First, we are targeting the input box with ID ‘input’ and naming it ‘inputBox’ so that we may attach an event listener to it.&lt;/p&gt;

&lt;p&gt;Second, we attach an event listener that is triggered when the input box is interacted with.&lt;/p&gt;

&lt;p&gt;So what’s next? Now that we have our event listener we can use the target property to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Retrieve the element of the fired event&lt;/li&gt;
&lt;li&gt;Access different properties of the fired event&lt;/li&gt;
&lt;li&gt;Modify properties and attributes of the element &lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Syntax:
&lt;/h2&gt;

&lt;p&gt;The Syntax for using the target property on events is not too different from other syntaxes that leverage dot notation; ‘target’ is added after the event with dot notation like below: &lt;/p&gt;

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

&lt;p&gt;These are a few examples of how you would use event.target to access different attributes of the event, such as the ‘value’ or a specific CSS element. In the first console.log we are simply returning the event object. The second console returns the actual value of the event which can prove useful when you’re looking to attach a command to a value return. The last example portrays how you can use event.target to modify CSS attributes.&lt;/p&gt;

&lt;p&gt;In summary, event.target is a way to access the value or specific attributes of an event when an event listener is attached. &lt;/p&gt;

&lt;p&gt;I hope this helped clear up some doubts you may have around how / when to use event.target! &lt;/p&gt;

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