<?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: Jaspreet kaur</title>
    <description>The latest articles on DEV Community by Jaspreet kaur (@jaspreet9795).</description>
    <link>https://dev.to/jaspreet9795</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%2F935273%2F428b1127-610a-4c32-962a-28b628c6b916.png</url>
      <title>DEV Community: Jaspreet kaur</title>
      <link>https://dev.to/jaspreet9795</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jaspreet9795"/>
    <language>en</language>
    <item>
      <title>React Native - Create an autocomplete search bar with Google Places autocomplete</title>
      <dc:creator>Jaspreet kaur</dc:creator>
      <pubDate>Sat, 06 May 2023 07:13:49 +0000</pubDate>
      <link>https://dev.to/jaspreet9795/react-native-create-an-autocomplete-search-bar-with-google-places-autocomplete-9of</link>
      <guid>https://dev.to/jaspreet9795/react-native-create-an-autocomplete-search-bar-with-google-places-autocomplete-9of</guid>
      <description>&lt;p&gt;For my last project, I created a React Native app for checking weather conditions powered by Open weather API. Open weather has different APIs to show current weather, hourly weather, weather forecast for 5 days and so on. The API can be called using latitude, longitude for any place Eg-&lt;br&gt;
&lt;a href=""&gt;https://api.openweathermap.org/data/2.5/weather?lat={lat}&amp;amp;lon={lon}&amp;amp;appid={API key}&lt;/a&gt;&lt;br&gt;
To make things easier, they also have built-in API requests by city name and other options as well Eg-&lt;br&gt;
&lt;a href=""&gt;https://api.openweathermap.org/data/2.5/weather?q={city name}&amp;amp;appid={API key}&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now to make this API work, all we need to do is get the city name from the search bar.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Search bar&lt;/strong&gt;&lt;br&gt;
A simple Search bar can be created using TextInput component in React Native and setting the state for place. By default, this search bar will not autocomplete the search input. I wanted to create a search bar with an autocomplete feature to add more convenience for the user. Now, there were some other options apart from google autocomplete component, but Google autocomplete library for react native was quite easier to understand and implement. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn2oc6okarylacmo0x4f2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn2oc6okarylacmo0x4f2.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Google Autocomplete search bar can be created by following the below steps- &lt;br&gt;
&lt;strong&gt;1. Download the react native  google places autocomplete library&lt;/strong&gt;- &lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Run `npm i react-native-google-places-autocomplete` 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;a href="https://www.npmjs.com/package/react-native-google-places-autocomplete" rel="noopener noreferrer"&gt;link&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.Create the Google Places API key&lt;/strong&gt;- &lt;br&gt;
If you are new to creating Google API keys, no need to panic, it's quite simple, you can  check out the &lt;a href="https://developers.google.com/maps/documentation/places/web-service/get-api-key" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;. &lt;br&gt;
Go to Google Cloud Console and select API &amp;amp; Services, then go to Enabled APIs &amp;amp; services: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8diyetlxpvkujlbzndja.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8diyetlxpvkujlbzndja.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
For next steps you can follow the below video, it will be easier to understand - &lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/VxCbR5kWn08"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You need to enable Places API and Maps JavaScript API in Google Cloud Console&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;One thing to pay attention to is, all above steps can only be accomplished when you update your billing information. Don’t worry, you won’t be charged right away, all APIs have different pricing ranges and google also gives free credit as well which  should be sufficient if you're using it for your personal projects. Google makes it compulsory for you to enable billing for your project before you can use the Places API or any other API. you can check the pricing and billing info &lt;a href="https://developers.google.com/maps/billing-and-pricing/pricing" rel="noopener noreferrer"&gt;here&lt;/a&gt; and &lt;a href="https://developers.google.com/maps/documentation/places/web-service/usage-and-billing" rel="noopener noreferrer"&gt;here too&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For easy understanding of how billing works you can go on &lt;a href="https://mapsplatform.google.com/pricing/?_gl=1%2A1vjksr1%2A_ga%2AMTM0OTQ5NTM4OC4xNjgxNTE0Mzc4%2A_ga_NRWSTWS78N%2AMTY4MjMwMzI5NS43LjAuMTY4MjMwMzI5NS4wLjAuMA..#places" rel="noopener noreferrer"&gt;Google Maps Platform&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Here you will see that a $200 credit is given to you for free every month, but if you exceed this limit then you will be charged. So you need to keep a track of your API calls per day or you can add a limit to your per day calls. Based on $200 credit you can check how many calls are free, by checking on the calculator slider provided on the same page. There are different APIs with different price ranges, choose the API you are working with to check allowed calls by setting the price range to $200, It's easy to check.  For a deeper understanding please go to the FAQ section on this page.&lt;/p&gt;

&lt;p&gt;It's always better to get assured of any kind of billing information by going through their documentation. I strongly recommend this. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3.Hiding the API key&lt;/strong&gt; -&lt;br&gt;
Once you have created the key you need to hide it,  to avoid any kind of misuse of the API key created by you. Afterall, your calls are limited right? and nobody likes sudden surprises since you have linked your billing info while creating this key. &lt;/p&gt;

&lt;p&gt;One way is by adding  Google recommended restrictions to your API key-&lt;br&gt;&lt;br&gt;
Google strongly recommends that you restrict your API keys by limiting their usage to only  those APIs needed for your application. &lt;a href="https://developers.google.com/maps/documentation/places/web-service/get-api-key" rel="noopener noreferrer"&gt;Restricting API keys&lt;/a&gt; adds security to your application by protecting it from unwarranted requests. &lt;/p&gt;

&lt;p&gt;The second way of hiding the key, is not to use the key directly in your code but hide it in the  .env file-If you put the key directly in your code and push it to github it will be visible to all and it can be misused.  (This is only applicable to personal projects that won’t be released on app stores). &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Download &lt;code&gt;npm i babel-plugin-inline-dotenv&lt;/code&gt;   in your react native project. Check the npm library &lt;a href="https://www.npmjs.com/package/babel-plugin-inline-dotenv" rel="noopener noreferrer"&gt;here&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Replace your babel.cofig.js file with below code: &lt;/p&gt;

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

module.exports = function(api) {
  api.cache(true);
  return {
    presets: ['babel-preset-expo'],
    plugins: [
      ["inline-dotenv",{
        path: '.env' 
      }]
    ],
  };
};


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

&lt;/div&gt;

&lt;p&gt;Now create a .env file  in the root directory and add your API keys there for eg: &lt;br&gt;
API_KEY= your copied api key &lt;/p&gt;

&lt;p&gt;You can use it in your code as: &lt;br&gt;
key = process.env.API_KEY&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4.Create a search bar with google autocomplete&lt;/strong&gt;- &lt;br&gt;
Use the useState hook to set the state for place.To understand the structure of the data received as a result of our place selection, just console.log the data. &lt;br&gt;
Then set the place to the city name received from data.&lt;/p&gt;

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

import { GooglePlacesAutocomplete } from 'react-native-google-places-autocomplete';

const GooglePlacesInput = () =&amp;gt; {
const [place, setPlace] = React.useState(' ')

return (
    &amp;lt;GooglePlacesAutocomplete
      placeholder='Search'
      onPress={(data, details = null) =&amp;gt; {
       fetchDetails={true}
        console.log(data, details);
        setPlace(data.structured_formatting.main_text)
      }}
      query={{
        key: process.env.API_KEY,
        language: 'en',
      }}
    /&amp;gt;
  );
};



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

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;5.Style your search bar with some CSS&lt;/strong&gt;: &lt;br&gt;
You can checkout the Styling section in &lt;a href="https://www.npmjs.com/package/react-native-google-places-autocomplete" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;br&gt;
GooglePlacesAutocomplete can be easily customized to meet the required styles of your app. Pass styles props to GooglePlacesAutocomplete with style objects for different elements. &lt;/p&gt;

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

&amp;lt;GooglePlacesAutocomplete
    placeholder='Enter Location'
    minLength={2}
   autoFocus={false}
    returnKeyType={'default'}
    fetchDetails={true}
    styles={{
    textInputContainer: {
      backgroundColor: 'grey',
    },
    textInput: {
      height: 38,
      color: '#5d5d5d',
      fontSize: 16,
    },
    predefinedPlacesDescription: {
      color: '#1faadb',
    },
  }}
placeholder='Search'
      onPress={(data, details = null) =&amp;gt; {
       fetchDetails={true}
        console.log(data, details);
        setPlace(data.structured_formatting.main_text)
      }}
      query={{
        key: process.env.API_KEY,
        language: 'en',
      }}  /&amp;gt;



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

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
In this article, we learnt how to create a Google Autocomplete search bar, create a Google place API key, how to hide the key, and use the GooglePlacesAutocomplete component into the code along with some CSS. Hope this will help you create your own search bar with autocomplete feature. &lt;/p&gt;

</description>
      <category>autocompletesearch</category>
      <category>googleplacesapi</category>
      <category>reactnative</category>
    </item>
    <item>
      <title>Locate users on Google map in React App!</title>
      <dc:creator>Jaspreet kaur</dc:creator>
      <pubDate>Fri, 13 Jan 2023 19:05:31 +0000</pubDate>
      <link>https://dev.to/jaspreet9795/locate-signed-in-user-on-google-map-in-react-app-1nof</link>
      <guid>https://dev.to/jaspreet9795/locate-signed-in-user-on-google-map-in-react-app-1nof</guid>
      <description>&lt;p&gt;While I was working on my project, which is like an online service providing platform, I had to show some user related  details including user's location too (based on the address provided by the user while signing in to my website) to the service provider.&lt;br&gt;&lt;br&gt;
For this project I used React js for frontend and rails for backend. &lt;/p&gt;

&lt;p&gt;My backend has a users table with address, state, &amp;amp; zip columns along with other columns about user details. While creating an account user will share these address details.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7nsdvx0wevuy8mf9xizc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7nsdvx0wevuy8mf9xizc.png" alt="Image description" width="800" height="535"&gt;&lt;/a&gt;&lt;br&gt;
Now, we have the address but we can't locate address directly on the map , you need coordinates for that. Below steps will help converting the address into coordinates and eventually show it on the google map. &lt;/p&gt;

&lt;p&gt;Getting started,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Install google map react =&amp;gt; npm install --save google-map-react&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then, get the particular user details for whom you want to show the location. You can get it either by fetching the api ("users/:id") or through the props from other components. That depends on the way your application is designed and how you want to code. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After that below code will help you get the coordinates. With this code you don't need to store the latitudes &amp;amp; longitudes in the database. It will dynamically convert the user address provided into coordinates. You just need to set the state for latitude, and longitude. &lt;br&gt;
And inside useEffect you need to pass dependency array with latitude &amp;amp; longitude state values. This will ensure that the fetch runs any time dependency value changes. &lt;br&gt;
Since we don't want to show only 1 user's location but for all whenever required. Hence, we need this dependency which ensures whenever the user details changes it will dynamically locate it on map. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Please note, here we are using google API key as well, make sure to secure/hide your API key before pushing your code to your GitHub.&lt;/strong&gt;&lt;/em&gt;&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, { useEffect, useState } from 'react'
import GoogleMapReact from 'google-map-react'

export default function SetCords ({user}) {
  const [lat, setLat] = useState()
  const [lon, setLon] = useState()
  const key = 'Your Google API key'
  let url = `https://maps.googleapis.com/maps/api/geocode/json?address=+${user.address},+${user.state},+${user.zip}&amp;amp;key=${key}`

useEffect(() =&amp;gt; {
    fetch(url)
      .then(res =&amp;gt; res.json())
      .then(res =&amp;gt; {
        if (res.status === 'OK') {
          console.log('Cordinates'+ JSON.stringify(res))
          setLat(res.results[0].geometry.location.lat)
          setLon(res.results[0].geometry.location.lng)
        } else if (res.status === 'ZERO_RESULTS') {
          alert(
            'Unable to process this location. Please revise location fields and try submitting again.'
          )
        }
      })
  },[lat, lon])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next,  you need show the above coordinates on map. Follow below code to show the map and marker on the map.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const renderMarker = (map, maps) =&amp;gt; {
    let marker = new maps.Marker({
      position: {lat: lat, lng: lon},
      map,
      title: 'User Location'
    })
    return marker;
  };

  return (
        &amp;lt;div style={{ height: '100vh', width: '100%' }}&amp;gt;
          &amp;lt;GoogleMapReact
            bootstrapURLKeys={{ key: key }}
            center={{lat: lat, lng: lon}}
            zoom={10}
            yesIWantToUseGoogleMapApiInternals= {true}
            onGoogleApiLoaded={({ map, maps }) =&amp;gt; {
              renderMarker(map, maps)
            }}
          &amp;gt;
          &amp;lt;/GoogleMapReact&amp;gt;
        &amp;lt;/div&amp;gt;
    )

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

&lt;/div&gt;



&lt;p&gt;Overall code looks like this:&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, { useEffect, useState } from 'react'
import GoogleMapReact from 'google-map-react'


export default function SetCords ({ user }) {
  const [lat, setLat] = useState()
  const [lon, setLon] = useState()
  const key = 'Your Google API key'
  let url = `https://maps.googleapis.com/maps/api/geocode/json?address=+${user.address},+${user.state},+${user.zip}&amp;amp;key=${key}`
  useEffect(() =&amp;gt; {
    fetch(url)
      .then(res =&amp;gt; res.json())
      .then(res =&amp;gt; {
        if (res.status === 'OK') {
          console.log('Cordinates' + JSON.stringify(res))
          setLat(res.results[0].geometry.location.lat)
          setLon(res.results[0].geometry.location.lng)
        } else if (res.status === 'ZERO_RESULTS') {
          alert(
            'Unable to process this location. Please revise location fields and try submitting again.'
          )
        }
      })
  },[lat, lon])

  const renderMarker = (map, maps) =&amp;gt; {
    let marker = new maps.Marker({
      position: {lat: lat, lng: lon},
      map,
      title: 'User Location'
    })
    return marker;
  };

  return (
      &amp;lt;div&amp;gt;

        &amp;lt;div style={{ height: '100vh', width: '100%' }}&amp;gt;
          &amp;lt;GoogleMapReact
            bootstrapURLKeys={{ key: key }}
            center={{lat: lat, lng: lon}}
            zoom={10}
            yesIWantToUseGoogleMapApiInternals= {true}
            onGoogleApiLoaded={({ map, maps }) =&amp;gt; {
              renderMarker(map, maps)
            }}
          &amp;gt;
          &amp;lt;/GoogleMapReact&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    )
}

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

&lt;/div&gt;



&lt;p&gt;Hope, this helps anyone who is new to google maps and want to convert address stored in the database into coordinates to locate it on the map.&lt;/p&gt;

</description>
      <category>cloudcomputing</category>
      <category>aws</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Fetch within Fetch !</title>
      <dc:creator>Jaspreet kaur</dc:creator>
      <pubDate>Fri, 16 Dec 2022 18:37:00 +0000</pubDate>
      <link>https://dev.to/jaspreet9795/fetch-within-fetch--1jkb</link>
      <guid>https://dev.to/jaspreet9795/fetch-within-fetch--1jkb</guid>
      <description>&lt;p&gt;For my last project, I had to display some information for which I had to fetch requests within fetch request.  &lt;/p&gt;

&lt;p&gt;As you can see, in my database structure, I had a project data which has a user_id related to that project and tasks that belongs to that project. This information in the database is being collected from 3 different tables projects, users, and tasks using association and serialization. &lt;br&gt;
(Just for information, I am using ruby on rails for backend and react for frontend).&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yXB6Fd7Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uv1d3fkzh2eac8w1qncs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yXB6Fd7Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uv1d3fkzh2eac8w1qncs.png" alt="Image description" width="880" height="624"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Below is the data I wanted to display. As you can notice, I wanted to display user name (Assigned member) instead of user_id and related tasks content. &lt;/p&gt;

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

&lt;p&gt;Now, in order to achieve above, I had to work with fetch requests in such a way that it gets the user data for the user_id related to that particular project as well as tasks for that project. &lt;/p&gt;

&lt;p&gt;In code below, &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;First its fetching the particular project data and setting the project state to that project. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In order to get the tasks, setting the projectTask state to project.tasks (this will give us the tasks array, you can console.log to check ) within that fetch request. And then you can display content inside return using tasks.content . &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now for the member info, we can only get the user_id from the current data structure, so in order to get the name we need to fetch the particular user's data which is related to the project being fetched(fetch(&lt;code&gt;/users/${project.user_id}&lt;/code&gt;)), &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you fetch users outside the project fetch  request, it will give you unrelated user data which is not relevant to that project since that will be an independent fetch request not related to any project. So for a particular user's info, you need to fetch inside the project's fetch since there you can grab that project's id and user_id related to project.&lt;br&gt;
This will fetch you the users' data of the user_id in that specific project and you can use user.name to display the name. This is just an example. Check the code below -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function DetailedProjectView (){
    const [project,setProject] = useState({});
    const [projectTasks, setProjectTasks] = useState([])
    const [user, setUser] = useState ({})
    const { id } = useParams();

    useEffect (()=&amp;gt; {
        fetch (`/projects/${id}`)
        .then (res=&amp;gt; res.json())
        .then (project =&amp;gt; {
            setProject(project);
            setProjectTasks(project.tasks);
            console.log(project.tasks)
            console.log(project.user_id)
            fetch (`/users/${project.user_id}`)
            .then (res=&amp;gt; res.json())
            .then (user =&amp;gt; setUser(user))
        })},[id]);

return (
   &amp;lt;&amp;gt; 
    &amp;lt;Card width={'100%'} align='center'&amp;gt;
        &amp;lt;CardHeader&amp;gt;
            &amp;lt;Heading size='md'&amp;gt;{project.project_title}&amp;lt;/Heading&amp;gt;
        &amp;lt;/CardHeader&amp;gt;
        &amp;lt;CardBody&amp;gt;
            &amp;lt;Text&amp;gt;{project.detail}&amp;lt;/Text&amp;gt;&amp;lt;br&amp;gt;&amp;lt;/br&amp;gt;
            &amp;lt;Text fontFamily={"cursive"}&amp;gt;&amp;lt;b&amp;gt;Assigned Member: &amp;lt;/b&amp;gt;&amp;lt;/Text&amp;gt;
            &amp;lt;Text&amp;gt;{user.first_name}&amp;lt;/Text&amp;gt;&amp;lt;br&amp;gt;&amp;lt;/br&amp;gt;
            &amp;lt;Text fontFamily={"cursive"} &amp;gt;&amp;lt;b&amp;gt;List of Tasks:&amp;lt;/b&amp;gt; &amp;lt;/Text&amp;gt;
            &amp;lt;OrderedList&amp;gt;
                {projectTasks.map((task) =&amp;gt; {
                    return (
            &amp;lt;ListItem key={task.id}&amp;gt;{task.content}&amp;lt;/ListItem&amp;gt;
             )})}
             &amp;lt;/OrderedList&amp;gt;
        &amp;lt;/CardBody&amp;gt;
    &amp;lt;/Card&amp;gt;     
    &amp;lt;/&amp;gt;
)}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hope, this helped someone who is a newbie like me to the coding world! When i was working on this problem, I couldn't find relevant answers on google. So, I thought to write this in my blog and help someone who is still learning to code like me. There must be for sure better ways to do this but this is what worked for me at that time. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Undo a specific migration in Ruby!</title>
      <dc:creator>Jaspreet kaur</dc:creator>
      <pubDate>Mon, 28 Nov 2022 07:06:15 +0000</pubDate>
      <link>https://dev.to/jaspreet9795/undo-a-specific-migration-in-ruby-8l6</link>
      <guid>https://dev.to/jaspreet9795/undo-a-specific-migration-in-ruby-8l6</guid>
      <description>&lt;p&gt;In Ruby, usually if you want to alter the table which you created using  the command Eg. "bundle exec rake db:create_migration NAME=create_games", and then "bundle exec rake db:migrate", you need to create a new migration, where you can add or change the columns. &lt;/p&gt;

&lt;p&gt;But there is another way how you can alter the table without creating a new migration. &lt;/p&gt;

&lt;p&gt;Check the migration status by running below in your terminal.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bundle exec rake db:migrate:status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will show you status of all migrations you created.&lt;br&gt;
If the status is up, that means this migration is active: it's been run, and has updated the database successfully!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;database: db/development.sqlite3

 Status   Migration ID    Migration Name
--------------------------------------------------
   up     20210719113216  Create games
   up     20210719113221  Create reviews
   up     20221110080300  Create users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, for eg. if you want to change the games table , you need run the command below, where VERSION= 'Migration ID' from the status.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rake db:migrate:down VERSION=20210719113216
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;database: db/development.sqlite3

 Status   Migration ID    Migration Name
--------------------------------------------------
  down    20210719113216  Create games
   up     20210719113221  Create reviews
   up     20221110080300  Create users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will change the status from active to inactive (down), plus it will remove the table from database and schema too, &lt;br&gt;
Check your schema file, there is no games table - &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LG8qLFs1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w1ohvoxrxuh3w5m99bgz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LG8qLFs1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w1ohvoxrxuh3w5m99bgz.png" alt="Image description" width="880" height="674"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you can edit the table in the create_games migration, save and run-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bundle exec rake db:migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create a new table with all the changes in the database and schema. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Create a simple Quiz using Ruby!</title>
      <dc:creator>Jaspreet kaur</dc:creator>
      <pubDate>Fri, 04 Nov 2022 18:36:05 +0000</pubDate>
      <link>https://dev.to/jaspreet9795/create-a-simple-quiz-using-ruby-2pe0</link>
      <guid>https://dev.to/jaspreet9795/create-a-simple-quiz-using-ruby-2pe0</guid>
      <description>&lt;p&gt;I am new to coding, and it's been a week I have started learning Ruby. For practicing the concepts I have learnt so far, I did a quiz exercise. As a beginner, I feel until &amp;amp; unless you start coding actually, you might always be in doubt if you have understood the concepts thoroughly or if you can implement your leanings confidently. Doing these small exercises can make your concepts clearer.&lt;/p&gt;

&lt;p&gt;So lets begin constructing a simple multiple choice quiz in ruby - &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1 &amp;gt;&amp;gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a class &lt;strong&gt;Quiz&lt;/strong&gt;. &lt;/li&gt;
&lt;li&gt;Inside this class - Initialize question and answer attributes
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Quiz 
    attr_accessor :question, :answer
    def initialize(question, answer)
        @question=question
        @answer= answer
    end 
end 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2 &amp;gt;&amp;gt;&lt;/strong&gt;&lt;br&gt;
After you create the class, you can write the questions you want to ask along with the answer choices. Each question will be assigned to a variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;question1= "How many sides does a square have?\n(a) 2\n(b) 4\n(c) 6"
question2 = "When it's raining what do you need?\n(a) A parachute\n(b) A teapot\n(c) An umbrella"
question3= "What sea creature has 8 legs?\n(a) An octopus\n(b) A dolphin\n(c) A crocodile"

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3 &amp;gt;&amp;gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create an array of questions. &lt;/li&gt;
&lt;li&gt;Inside this array we will create new question instances or objects using our Quiz class (Quiz.new). &lt;/li&gt;
&lt;li&gt;Since we have initialized question and answer attributes above, we can pass these attributes to our new instances. &lt;/li&gt;
&lt;li&gt;Each question is a new instance/object which will have unique question (questions that we created ) and answer( the correct choice)  attribute. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now we have an array that stores all the questions for our quiz with correct answers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;questions= [
    Quiz.new(question1,"b"),
    Quiz.new(question2,"c"),
    Quiz.new(question3,"a")
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4 &amp;gt;&amp;gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Next we need to run the Quiz. &lt;/li&gt;
&lt;li&gt;For this we need to create a method that will run our quiz and calculate the score. &lt;/li&gt;
&lt;li&gt;This method should be able to go through each question in the array and ask the user that particular question, get their answer and check if that answer is correct or not.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def run_quiz(questions)
    answer=""
    for item in questions
        puts item.question
        answer= gets.chomp()
    end 
end 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;In the code above, we are passing questions array to the run_quiz method. &lt;/li&gt;
&lt;li&gt;We created an answer variable with (""), This basically will store the user's answers.&lt;/li&gt;
&lt;li&gt;Next we create a loop to iterate through each item in the questions array, and prints the question for user. (item.question), we called the question attribute on item which will display the question(question1/ question2/ question3)for the current item we are looping through. &lt;/li&gt;
&lt;li&gt;Then we are getting user's answer (answer= gets.chomp()) (.chomp() basically removes the new line that gets entered when users click enter). &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 5 &amp;gt;&amp;gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Find the Score.&lt;/li&gt;
&lt;li&gt;Add a new score variable with 0 initial value. &lt;/li&gt;
&lt;li&gt;With the help of if statement find out if your answer is correct or not. If correct add 1 to the score each time.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def run_quiz(questions)
    answer=""
    score=0
    for item in questions
        puts item.question
        answer= gets.chomp()
        if answer==item.answer
            score+=1
        end 
    end 
    puts ("Your Score is " + score.to_s + "/"+ questions.length().to_s)
end 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 6 &amp;gt;&amp;gt;&lt;/strong&gt;&lt;br&gt;
Finally , call the run_quiz method with argument of questions.&lt;br&gt;
Overall the code looks like below -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Quiz 
    attr_accessor :question, :answer
    def initialize(question, answer)
        @question=question
        @answer= answer
    end 
end 

question1= "How many sides does a square have?\n(a) 2\n(b) 4\n(c) 6"
question2 = "When it's raining what do you need?\n(a) A parachute\n(b) A teapot\n(c) An umbrella"
question3= "What sea creature has 8 legs?\n(a) An octopus\n(b) A dolphin\n(c) A crocodile"

questions= [
    Quiz.new(question1,"b"),
    Quiz.new(question2,"c"),
    Quiz.new(question3,"a")
]

def run_quiz(questions)
    answer=""
    score=0
    for item in questions
        puts item.question
        answer= gets.chomp()
        if answer==item.answer
            score+=1
        end 
    end 
    puts ("Your Score is " + score.to_s + "/"+ questions.length().to_s)
end 

run_quiz(questions)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 7&amp;gt;&amp;gt;&lt;/strong&gt;&lt;br&gt;
Run your ruby file in the terminal, quiz should look like below-&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhvth48sl5b8xdz9ecacy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhvth48sl5b8xdz9ecacy.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And that's it. Hope you enjoyed constructing your own quiz!!&lt;/p&gt;

</description>
      <category>ruby</category>
    </item>
    <item>
      <title>Javascript vs React!</title>
      <dc:creator>Jaspreet kaur</dc:creator>
      <pubDate>Fri, 14 Oct 2022 19:33:19 +0000</pubDate>
      <link>https://dev.to/jaspreet9795/javascript-vs-react-550</link>
      <guid>https://dev.to/jaspreet9795/javascript-vs-react-550</guid>
      <description>&lt;ul&gt;
&lt;li&gt;If React is written in JavaScript, then how is it different than the plain JavaScript? &lt;/li&gt;
&lt;li&gt;JavaScript can also be used to build Web Applications, then why do we need React? &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I would say React is an abstraction on top of JavaScript. React is basically a JavaScript Library which is popular because of its dynamic approach.  Let's look at some of the few advantages of using React over JavaScript. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Nqh9thzN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c4kj8ruxvkal215ti9ee.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Nqh9thzN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c4kj8ruxvkal215ti9ee.png" alt="Image description" width="880" height="716"&gt;&lt;/a&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8LKJfe7n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7npuutn7uixa659du2p8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8LKJfe7n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7npuutn7uixa659du2p8.png" alt="Image description" width="880" height="625"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I tried adding few basic differences only , but there's a lot more to it. I hope it helped you in giving an overview of React and its usage. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion-&lt;/strong&gt;&lt;br&gt;
It's completely your choice whether to use JavaScript or React for your web development. As mentioned, For scalable and more complex applications React would work better than JavaScript. But if your application doesn't have much complexity, you might want to use JavaScript because of its simpler syntax and basic setup. &lt;/p&gt;

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