<?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: Amdadul Haque</title>
    <description>The latest articles on DEV Community by Amdadul Haque (@amdadulhaque).</description>
    <link>https://dev.to/amdadulhaque</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%2F876874%2F64ec75b8-3c9f-4592-a666-f2f4543175bd.jpg</url>
      <title>DEV Community: Amdadul Haque</title>
      <link>https://dev.to/amdadulhaque</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/amdadulhaque"/>
    <language>en</language>
    <item>
      <title>Push to multiple remote repos from a single local repo</title>
      <dc:creator>Amdadul Haque</dc:creator>
      <pubDate>Wed, 20 Nov 2024 08:47:52 +0000</pubDate>
      <link>https://dev.to/amdadulhaque/push-to-multiple-remote-repos-from-a-single-local-repo-46i4</link>
      <guid>https://dev.to/amdadulhaque/push-to-multiple-remote-repos-from-a-single-local-repo-46i4</guid>
      <description>&lt;p&gt;Are you working on a front-end project for clients? The client set up a github repository and you need to push the code in that repo. Do you want to see a preview of how it looks on the live site? Here is a solution where you can set up another repo in your personal github account and host it for free in vercel or netlify. &lt;/p&gt;

&lt;h2&gt;
  
  
  Add remote repo
&lt;/h2&gt;

&lt;p&gt;We know that we use&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git remote add origin &amp;lt;url_to_our_github_repo&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;here the &lt;code&gt;origin&lt;/code&gt; word is kind of a key and name to keep in mind for the github repo we have added.&lt;/p&gt;

&lt;p&gt;So we can add another remote repo and then we need to select another name for that remote repo, lets have we choose a name &lt;code&gt;dev&lt;/code&gt; so the command will be&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git remote add dev &amp;lt;url_to_another_github_repo&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Push
&lt;/h2&gt;

&lt;p&gt;For pushing to remote repo (origin)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git push origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;dev repo&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git push dev main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>git</category>
      <category>github</category>
      <category>webdev</category>
      <category>frontend</category>
    </item>
    <item>
      <title>React Form Validation with Formik and Yup</title>
      <dc:creator>Amdadul Haque</dc:creator>
      <pubDate>Sat, 06 May 2023 04:21:26 +0000</pubDate>
      <link>https://dev.to/amdadulhaque/react-form-validation-with-formik-and-yup-39im</link>
      <guid>https://dev.to/amdadulhaque/react-form-validation-with-formik-and-yup-39im</guid>
      <description>&lt;p&gt;Form validation is an important part of any web application. It ensures that users provide valid input before submitting a form. In this blog post, we will learn how to implement form validation using Formik and yup in a React application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;To get started, we need to install the required packages. We will be using formik for managing our form state and yup for validation.&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 formik yup
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Setting up the form
&lt;/h2&gt;

&lt;p&gt;Let's start by creating a simple form with two fields - name 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;import React from 'react';
import { Formik, Form, Field, ErrorMessage } from 'formik';

const initialValues = {
  name: '',
  email: '',
};

const onSubmit = (values) =&amp;gt; {
  console.log(values);
};

const App = () =&amp;gt; {
  return (
    &amp;lt;div&amp;gt;
      &amp;lt;h1&amp;gt;Form Validation Example&amp;lt;/h1&amp;gt;
      &amp;lt;Formik initialValues={initialValues} onSubmit={onSubmit}&amp;gt;
        &amp;lt;Form&amp;gt;
          &amp;lt;div&amp;gt;
            &amp;lt;label htmlFor="name"&amp;gt;Name:&amp;lt;/label&amp;gt;
            &amp;lt;Field type="text" id="name" name="name" /&amp;gt;
            &amp;lt;ErrorMessage name="name" /&amp;gt;
          &amp;lt;/div&amp;gt;
          &amp;lt;div&amp;gt;
            &amp;lt;label htmlFor="email"&amp;gt;Email:&amp;lt;/label&amp;gt;
            &amp;lt;Field type="email" id="email" name="email" /&amp;gt;
            &amp;lt;ErrorMessage name="email" /&amp;gt;
          &amp;lt;/div&amp;gt;
          &amp;lt;button type="submit"&amp;gt;Submit&amp;lt;/button&amp;gt;
        &amp;lt;/Form&amp;gt;
      &amp;lt;/Formik&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};

export default App;

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

&lt;/div&gt;



&lt;p&gt;In the code above, we have defined a form with two input fields - name and email. We have also defined an onSubmit function that will be called when the form is submitted.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding validation
&lt;/h2&gt;

&lt;p&gt;Now, let's add validation to our form using yup. We will start by creating a validation schema for our form.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import * as Yup from 'yup';

const validationSchema = Yup.object({
  name: Yup.string().required('Name is required'),
  email: Yup.string().email('Invalid email address').required('Email is required'),
});

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

&lt;/div&gt;



&lt;p&gt;In the code above, we have defined a validation schema using yup. We have specified that the name field is required and the email field must be a valid email address.&lt;br&gt;
Next, we will update our Formik component to use the validation schema.&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;Formik initialValues={initialValues} onSubmit={onSubmit} validationSchema={validationSchema}&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;Finally, we will update our form inputs to display validation errors.&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;div&amp;gt;
  &amp;lt;label htmlFor="name"&amp;gt;Name:&amp;lt;/label&amp;gt;
  &amp;lt;Field type="text" id="name" name="name" /&amp;gt;
  &amp;lt;ErrorMessage name="name" /&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;div&amp;gt;
  &amp;lt;label htmlFor="email"&amp;gt;Email:&amp;lt;/label&amp;gt;
  &amp;lt;Field type="email" id="email" name="email" /&amp;gt;
  &amp;lt;ErrorMessage name="email" /&amp;gt;
&amp;lt;/div&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;In the code above, we are using the ErrorMessage component from formik to display validation errors for each input field.&lt;/p&gt;

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

&lt;p&gt;In this blog post, we have learned how to implement form validation using Formik and yup in a React application. Formik and yup provide a simple and powerful way to manage form state and validation. With these tools, you can easily create forms that are robust and user-friendly.&lt;/p&gt;

</description>
      <category>formik</category>
      <category>yup</category>
      <category>react</category>
      <category>form</category>
    </item>
  </channel>
</rss>
