<?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: Anlisha Maharjan</title>
    <description>The latest articles on Forem by Anlisha Maharjan (@anlishamaharjan).</description>
    <link>https://forem.com/anlishamaharjan</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%2F852936%2Fe89a83e1-5ec3-479b-9fc3-65ca99daf7d5.jpg</url>
      <title>Forem: Anlisha Maharjan</title>
      <link>https://forem.com/anlishamaharjan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/anlishamaharjan"/>
    <language>en</language>
    <item>
      <title>Deploy Laravel with GitHub Actions on Shared Hosting</title>
      <dc:creator>Anlisha Maharjan</dc:creator>
      <pubDate>Mon, 09 Jan 2023 03:45:59 +0000</pubDate>
      <link>https://forem.com/anlishamaharjan/deploy-laravel-with-github-actions-on-shared-hosting-1pal</link>
      <guid>https://forem.com/anlishamaharjan/deploy-laravel-with-github-actions-on-shared-hosting-1pal</guid>
      <description>&lt;p&gt;Let’s see the process to deploy Laravel app on shared hosting with SSH GitHub Action.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Set up SSH keys in the server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Set up Laravel project in GitHub.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s start!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create Deployment Script:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Run the command below in the root of the project directory. A deploy.sh file is created inside the scripts folder. Paste the code snippet below into the deploy.sh file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir .scripts/
touch .scripts/deploy.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Setup GitHub Actions:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Option 1:&lt;/p&gt;

&lt;p&gt;Run the command below in the root of the project directory. A ci.yml file is created inside the workflows folder, the file can have any name but it should end with a .yml extension. Write the configuration code snippet below into the ci.yml file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir .github/
mkdir .github/workflows/
touch .github/workflows/ci.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Option 2:&lt;/p&gt;

&lt;p&gt;In the GitHub repository, click on  &lt;strong&gt;Actions &amp;gt; set up a workflow yourself&lt;/strong&gt; and write the configuration code snippet below into the ci.yml file. The file can have any name but it should end with a .yml extension.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;Let me explain what each section does.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name: Deploy on push master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Just specifying a name for the workflow.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;on:
  push:
    branches:
      - master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above snippet triggers the workflow when one pushes to the &lt;em&gt;master&lt;/em&gt; branch.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jobs:
  web-deploy:
    name: Deploy
    runs-on: ubuntu-latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;jobs&lt;/em&gt; – Group all the jobs that run in the workflow. Specifying and setting up a &lt;em&gt;web-deploy&lt;/em&gt; job.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;runs-on: ubuntu-latest&lt;/em&gt; – Configures to run the workflow using the latest version of Ubuntu.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;steps:
    - name: 🚚 Get latest code
        uses: actions/checkout@v2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;steps&lt;/em&gt; – Group all the steps that run in the &lt;em&gt;web-deploy&lt;/em&gt; job.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;uses: actions/checkout@v2&lt;/em&gt; – Check-out repository so the workflow can access it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- name: 📂 Deploy to server via ssh
        uses: appleboy/ssh-action@v0.1.7
        with:
          host: ${{ secrets.HOST }}
          username: ${{ secrets.USERNAME }}
          password: ${{ secrets.PASSWORD }}
          port: ${{ secrets.PORT }}
          script: "cd /var/www/html &amp;amp;&amp;amp; sh ./.scripts/deploy.sh"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using appleboy/ssh-action; any ssh commands can be remotely executed to the shared hosting server with SSH username/password provided.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Add GitHub Secrets:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Goto  &lt;strong&gt;Settings&lt;/strong&gt; tab on the GitHub repository, click on  &lt;strong&gt;Secrets&lt;/strong&gt;  &amp;gt;  &lt;strong&gt;Actions&lt;/strong&gt;  &amp;gt; &lt;strong&gt;New Repository Secret&lt;/strong&gt; to add the server host, ssh username, password, and port.&lt;/p&gt;

&lt;p&gt;For example: For Server host:  &lt;strong&gt;HOST&lt;/strong&gt;  as Name and  &lt;strong&gt;your server IP address&lt;/strong&gt;  as Value. For SSH port:  &lt;strong&gt;PORT&lt;/strong&gt;  as Name and  &lt;strong&gt;your ssh port&lt;/strong&gt;  as Value. &lt;strong&gt;22&lt;/strong&gt; is the default ssh port. For example: For SSH username:  &lt;strong&gt;USERNAME&lt;/strong&gt;  as Name and &lt;strong&gt;run whoami on your server and use the result&lt;/strong&gt; as Value.&lt;/p&gt;

&lt;p&gt;To access variables in the pipeline use the format below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;${{ secrets.HOST }}
${{ secrets.USERNAME }}
${{ secrets.PASSWORD }}
${{ secrets.PORT }}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&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%2Fhqgs97tc1gt49zpwu2km.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%2Fhqgs97tc1gt49zpwu2km.png" width="800" height="517"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now anytime one pushes to the master branch, the pipeline starts running a &lt;em&gt;web-deploy&lt;/em&gt; job that deploys the Laravel app.&lt;/p&gt;

&lt;p&gt;Goto  &lt;strong&gt;Actions&lt;/strong&gt;  tab to monitor whether it’s running, successfully deployed, or failed.&lt;/p&gt;

&lt;p&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%2Fmwy13ppndfxl1kte058y.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%2Fmwy13ppndfxl1kte058y.png" width="800" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This concludes a CI/CD pipeline for Laravel on GitHub. Thanks for reading!&lt;/p&gt;

&lt;p&gt;The post &lt;a href="https://anlisha.com.np/blog/deploy-laravel-with-github-actions-on-shared-hosting/" rel="noopener noreferrer"&gt;Deploy Laravel with GitHub Actions on Shared Hosting&lt;/a&gt; first appeared on &lt;a href="https://anlisha.com.np/blog" rel="noopener noreferrer"&gt;Anlisha Maharjan&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>cicd</category>
      <category>laravel</category>
    </item>
    <item>
      <title>Deploy React with GitHub Actions on Shared Hosting</title>
      <dc:creator>Anlisha Maharjan</dc:creator>
      <pubDate>Wed, 28 Dec 2022 13:40:59 +0000</pubDate>
      <link>https://forem.com/anlishamaharjan/deploy-react-with-github-actions-on-shared-hosting-1c8e</link>
      <guid>https://forem.com/anlishamaharjan/deploy-react-with-github-actions-on-shared-hosting-1c8e</guid>
      <description>&lt;p&gt;Let’s see the process to deploy React app on shared hosting with FTP Deploy GitHub Action.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Set up an FTP account in cPanel.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Setup React Project in GitHub.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s start!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setup GitHub Actions:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Option 1:&lt;/p&gt;

&lt;p&gt;Run the command below in the root of the project directory. A ci.yml file is created inside the workflows folder, the file can have any name but it should end with a .yml extension. Write the configuration code snippet below into the ci.yml file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir .github/
mkdir .github/workflows/
touch .github/workflows/ci.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Option 2:&lt;/p&gt;

&lt;p&gt;In the GitHub repository, click on  &lt;strong&gt;Actions &amp;gt; set up a workflow yourself&lt;/strong&gt; and write the configuration code snippet below into the ci.yml file. The file can have any name but it should end with a .yml extension.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;Let me explain what each section does.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name: Deploy on push master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Just specifying a name for the workflow.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;on:
  push:
    branches:
      - master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above snippet triggers the workflow when one pushes to the &lt;em&gt;master&lt;/em&gt; branch.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jobs:
  web-deploy:
    name: Deploy
    runs-on: ubuntu-latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;jobs&lt;/em&gt; – Group together all the jobs that run in the workflow. Specifying and setting up a &lt;em&gt;web-deploy&lt;/em&gt; job.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;runs-on: ubuntu-latest&lt;/em&gt; – Configures to run the workflow using the latest version of Ubuntu.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;strategy:
      matrix:
        node-version: [16.x]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;matrix&lt;/em&gt; accompanied by the node-version tells the workflow to run &lt;em&gt;web-deploy&lt;/em&gt; on the specified node version.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;steps:
    - name: 🚚 Get latest code
        uses: actions/checkout@v2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;steps&lt;/em&gt; – Group together all the steps that run in the &lt;em&gt;web-deploy&lt;/em&gt; job.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;uses: actions/checkout@v2&lt;/em&gt; – Check-out repository so the workflow can access it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@master
      with:
        node-version: ${{ matrix.node-version }}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;uses: actions/setup-node@master&lt;/em&gt; – Installs the specified node version(16) in the CI environment.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; - name: Copy .env.prod.example to .env
      run: cp .env.prod.example .env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;run: cp .env.prod.example .env&lt;/em&gt; – Creates a .env with required environment variables. (Important because .env is always added to .gitignore).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- name: 🔨 Build Project 
      run: |
        npm install
        npm run build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;run: npm install&lt;/em&gt; – Using npm to install the package node dependencies.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;run: npm run build&lt;/em&gt; – Builds React project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- name: 📂 Sync files
        uses: SamKirkland/FTP-Deploy-Action@4.3.3
        with:
          server: ${{ secrets.SERVER }}
          username: ${{ secrets.FTP_USERNAME }}
          password: ${{ secrets.FTP_PASSWORD }}
          local-dir: build/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Transfers files from the &lt;em&gt;build&lt;/em&gt; folder to the shared hosting server using FTP credentials.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Add GitHub Secrets:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Goto  &lt;strong&gt;Settings&lt;/strong&gt; tab on the GitHub repository, click on  &lt;strong&gt;Secrets&lt;/strong&gt;  &amp;gt;  &lt;strong&gt;Actions&lt;/strong&gt;  &amp;gt; &lt;strong&gt;New Repository Secret&lt;/strong&gt; to add the FTP server, account username, and password.&lt;/p&gt;

&lt;p&gt;For example, for FTP username:  &lt;strong&gt;FTP_USERNAME&lt;/strong&gt;  as Name and  &lt;strong&gt;&lt;a href="mailto:zon@zon.com"&gt;zon@zon.com&lt;/a&gt;&lt;/strong&gt;  as Value.&lt;/p&gt;

&lt;p&gt;To access variables in the pipeline use the format below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;${{ secrets.SERVER }}
${{ secrets.FTP_USERNAME }}
${{ secrets.FTP_PASSWORD }}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&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%2Frnxb6l5qx8a7b8pisf3b.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%2Frnxb6l5qx8a7b8pisf3b.png" width="800" height="521"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now anytime one pushes to the master branch, the pipeline starts running &lt;em&gt;web-deploy&lt;/em&gt; job which builds and deploys the react app.&lt;/p&gt;

&lt;p&gt;Goto  &lt;strong&gt;Actions&lt;/strong&gt;  tab to monitor whether it’s running, successfully deployed, or failed.&lt;/p&gt;

&lt;p&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%2Ftpc3xlmaa2zyfdogski4.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%2Ftpc3xlmaa2zyfdogski4.png" width="800" height="345"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This concludes a CI/CD pipeline on GitHub. Thanks for reading!&lt;/p&gt;

&lt;p&gt;The post &lt;a href="https://anlisha.com.np/blog/deploy-react-with-github-actions-on-shared-hosting/" rel="noopener noreferrer"&gt;Deploy React with GitHub Actions on Shared Hosting&lt;/a&gt; first appeared on &lt;a href="https://anlisha.com.np/blog" rel="noopener noreferrer"&gt;Anlisha Maharjan&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>cicd</category>
      <category>react</category>
    </item>
    <item>
      <title>Yup.array validate object property is unique with Formik in React.</title>
      <dc:creator>Anlisha Maharjan</dc:creator>
      <pubDate>Tue, 29 Nov 2022 08:24:24 +0000</pubDate>
      <link>https://forem.com/anlishamaharjan/yuparray-validate-object-property-is-unique-with-formik-in-react-4dkn</link>
      <guid>https://forem.com/anlishamaharjan/yuparray-validate-object-property-is-unique-with-formik-in-react-4dkn</guid>
      <description>&lt;p&gt;The requirement is to validate objects in  &lt;strong&gt;users&lt;/strong&gt;  array has unique  &lt;strong&gt;name&lt;/strong&gt;  property.&lt;/p&gt;

&lt;p&gt;Define a custom method in Yup using &lt;strong&gt;Yup.addMethod&lt;/strong&gt;. Yup.js provides this function to conveniently reuse test functions. Function has to either return  &lt;strong&gt;true&lt;/strong&gt;  or  &lt;strong&gt;false&lt;/strong&gt;  to indicate if testing has failed or not respectively, or a new  &lt;strong&gt;ValidationError&lt;/strong&gt;  created through &lt;strong&gt;this.createError()&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;Yup.addMethod(Yup.array, "unique", function (message, path) {
  return this.test("unique", message, function (list) {
    const mapper = (x) =&amp;gt; get(x, path);
    const set = [...new Set(list.map(mapper))];
    const isUnique = list.length === set.length;
    if (isUnique) {
      return true;
    }
    const idx = list.findIndex((l, i) =&amp;gt; mapper(l) !== set[i]);
    return this.createError({path: `users[${idx}].${path}`,message});
 });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;With Yup, we create a Yup formatted object that resembles our intended schema for an object.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const schema = Yup.object().shape({
 users: Yup.array().of(
   Yup.object().shape({
     name: Yup.string().required("Name is required"),        
   })).unique("Duplicate user", "name")
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Formik has a special config option / prop for Yup object schemas called validationSchema which will automatically transform Yup’s validation errors into a pretty object whose keys match values and touched. Set the validationSchema option to the schema created above.&lt;/p&gt;

&lt;p&gt;Use FieldArray that helps with common array/list manipulations. Pass it a name property &lt;strong&gt;name=”users”&lt;/strong&gt;. FieldArray will give access to array helper methods via render props.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;Note on line 57, &lt;strong&gt;arrayHelpers.push&lt;/strong&gt; add a value to the end of an array. Similarly, &lt;strong&gt;arrayHelpers.remove&lt;/strong&gt; on line 104 remove an element at an index of an array and return it.&lt;/p&gt;

&lt;p&gt;Field hooks up inputs to Formik. Note the name attribute on line 82; it uses to match up with Formik state.  &lt;/p&gt;

&lt;p&gt;Thank you for reading!&lt;/p&gt;

&lt;p&gt;The post &lt;a href="https://anlisha.com.np/blog/yup-array-validate-object-property-is-unique-with-formik-in-react/" rel="noopener noreferrer"&gt;Yup.array validate object property is unique with Formik in React.&lt;/a&gt; first appeared on &lt;a href="https://anlisha.com.np/blog" rel="noopener noreferrer"&gt;Anlisha Maharjan&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>react</category>
    </item>
    <item>
      <title>Setup Bitbucket CI/CD for React</title>
      <dc:creator>Anlisha Maharjan</dc:creator>
      <pubDate>Tue, 25 Oct 2022 17:42:26 +0000</pubDate>
      <link>https://forem.com/anlishamaharjan/setup-bitbucket-cicd-for-react-54d2</link>
      <guid>https://forem.com/anlishamaharjan/setup-bitbucket-cicd-for-react-54d2</guid>
      <description>&lt;p&gt;Continuous integration (CI) validates all the stages of the development process from merging codes to testing builds while optimizing the code release cycles. Continuous deployment (CD) focuses on setting up a bundled artifact into a production environment in the fastest way possible which automates the whole deployment process.&lt;/p&gt;

&lt;p&gt;Here is a set of steps to integrate the Bitbucket CI/CD pipeline with React application; assuming that you have already set up React application repository in Bitbucket.&lt;/p&gt;

&lt;h2&gt;
  
  
  Enable bitbucket pipelines
&lt;/h2&gt;

&lt;p&gt;Go to &lt;code&gt;Repository settings → Pipelines settings&lt;/code&gt;. Enable the CI/CD pipeline by clicking on the &lt;code&gt;Enable Pipelines&lt;/code&gt; button.&lt;/p&gt;

&lt;p&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%2Fsivpruxdiqqp5p2jwcmv.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%2Fsivpruxdiqqp5p2jwcmv.png" width="789" height="298"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Generate SSH keys
&lt;/h2&gt;

&lt;p&gt;Generate a new SSH key pair (recommended):&lt;br&gt;&lt;br&gt;
Go to &lt;code&gt;Repository settings → SSH keys → Generate keys&lt;/code&gt; to generate public key and private key.&lt;/p&gt;

&lt;p&gt;Add an existing key pair:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Go to Repository settings → SSH keys → Use my own keys&lt;/code&gt; and paste the private and public key into the provided fields, then Save.&lt;/p&gt;

&lt;p&gt;Install the public key on the remote host before Pipelines can authenticate with that host.&lt;/p&gt;

&lt;p&gt;For EC2; paste the public key to file: &lt;code&gt;/home/ec2-user/.ssh/authorized_keys&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I prefer to add a one-liner description such as: &lt;code&gt;#Bitbucket CI/CD Pipeline&lt;/code&gt;&lt;/p&gt;

&lt;p&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%2Ffiz5ll6oxzwtko54myrs.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%2Ffiz5ll6oxzwtko54myrs.png" width="800" height="531"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Setup known hosts
&lt;/h2&gt;

&lt;p&gt;Pipelines provide a way to store, and inspect, the fingerprint of a remote host, along with the host address; for the sole reason to verify that the public key presented by a remote host actually matches the identity of that host, to help you detect spoofing and man-in-the-middle attacks.&lt;br&gt;&lt;br&gt;
Go to &lt;code&gt;Repository settings → SSH keys&lt;/code&gt; and enter the server IP address and select the &lt;code&gt;Fetch&lt;/code&gt; button to see the host’s fingerprint.&lt;/p&gt;

&lt;p&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%2Ff0za77q6uhfmy2556ke9.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%2Ff0za77q6uhfmy2556ke9.png" width="800" height="212"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Add .env.prod.example in React JS repository
&lt;/h2&gt;

&lt;p&gt;Copy .env to .env.prod.example. Setup .env.prod.example with necessary values. For example: &lt;code&gt;REACT_APP_API_URL=(Your Production API Url)&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Add bitbucket-pipeplines.yml in React JS application
&lt;/h2&gt;

&lt;p&gt;Add the &lt;code&gt;bitbucket-pipelines.yml&lt;/code&gt; file below to the root directory of the React repository to run the CI/CD pipeline.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;In the yml file; When pull requests are merged in master branch the first step “Build React (Prod Server)” scripts are executed. This step mainly focus on installing latest npm packages and building the React application. Next step “Deployment (Prod Server)” focus on deploying the build folder to the server.&lt;br&gt;&lt;br&gt;
Note the &lt;code&gt;$PROD_USER&lt;/code&gt;, &lt;code&gt;$PROD_SERVER&lt;/code&gt; variables.&lt;/p&gt;

&lt;h2&gt;
  
  
  Add repository variables
&lt;/h2&gt;

&lt;p&gt;Go to &lt;code&gt;Repository settings → Repository variables&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Pipelines variables added at the repository level can be accessed from the bitbucket-pipelines.yml file or any script in the following way: &lt;code&gt;$PROD_USER&lt;/code&gt; where &lt;code&gt;PROD_USER&lt;/code&gt; is the name of the variable.&lt;br&gt;&lt;br&gt;
For EC2; Set the values of variables as follows:&lt;br&gt;&lt;br&gt;
&lt;code&gt;PROD_USER&lt;/code&gt; – ubuntu&lt;br&gt;&lt;br&gt;
&lt;code&gt;PROD_SERVER&lt;/code&gt; – (Your Server IP Address)&lt;br&gt;&lt;br&gt;
&lt;code&gt;PROD_BUILD_FOLDER&lt;/code&gt; – build&lt;br&gt;&lt;br&gt;
&lt;code&gt;PROD_REMOTE_DESTINATION_PATH&lt;/code&gt; – (Your Server Path)&lt;/p&gt;

&lt;p&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%2F5lic8ag4epy52r9aej7m.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%2F5lic8ag4epy52r9aej7m.png" width="800" height="643"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  CI/CD pipeline process
&lt;/h2&gt;

&lt;p&gt;Go to &lt;code&gt;Pipelines&lt;/code&gt; to see the list of all pipeline processes. Now when pull requests are merged into the master branch, the pipeline will run. A pipeline process runs all the scripts defined in the bitbucket-pipelines.yml file.&lt;/p&gt;

&lt;p&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%2F1dmt8ew743ud5kbjyq4k.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%2F1dmt8ew743ud5kbjyq4k.png" width="800" height="308"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And that’s it. Happy Reading!!&lt;/p&gt;

&lt;p&gt;The post &lt;a href="https://anlisha.com.np/blog/bitbucket-ci-cd/" rel="noopener noreferrer"&gt;Setup Bitbucket CI/CD for React&lt;/a&gt; first appeared on &lt;a href="https://anlisha.com.np/blog" rel="noopener noreferrer"&gt;Anlisha Maharjan&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>cicd</category>
      <category>react</category>
    </item>
    <item>
      <title>Google Maps API Directions Service in React – Plot efficient route on map with total distance and duration.</title>
      <dc:creator>Anlisha Maharjan</dc:creator>
      <pubDate>Wed, 24 Aug 2022 04:15:30 +0000</pubDate>
      <link>https://forem.com/anlishamaharjan/google-maps-api-directions-service-in-react-plot-efficient-route-on-map-with-total-distance-and-duration-4iok</link>
      <guid>https://forem.com/anlishamaharjan/google-maps-api-directions-service-in-react-plot-efficient-route-on-map-with-total-distance-and-duration-4iok</guid>
      <description>&lt;p&gt;&lt;strong&gt;Use Case:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One can enter source and destination address; For the address field, google places autocomplete is implemented.&lt;/li&gt;
&lt;li&gt;One can also add multiple way-points/stops between source and destination address.&lt;/li&gt;
&lt;li&gt;On change in any address field, The Map and the Directions service is initialized to plot the driving directions and route on map and display the total distance and total duration.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Final Demo!&lt;/strong&gt;&lt;/p&gt;

&lt;p&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%2Fc75vuerjr31y1ptmv5nj.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%2Fc75vuerjr31y1ptmv5nj.png" width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step1 — Enable Directions API for Google Maps API key&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you are new to Google Maps API key, I recommend you to have a look at it &lt;a href="https://developers.google.com/maps/documentation/directions/cloud-setup" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step2 — Start Basic CRA&lt;/strong&gt;  &lt;strong&gt;and Install packages&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;npx create-react-app axon
cd axon
npm install @mui/material @emotion/react @emotion/styled
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This will create a basic CRA. We also installed MUI 5 for creating UI components.&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-google-maps/api use-places-autocomplete formik moment
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This will install &lt;code&gt;react-google-maps/api&lt;/code&gt; and &lt;code&gt;use-places-autocomplete&lt;/code&gt; packages required.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step3 — Include Maps JavaScript Library&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Include the google maps client-side library in &lt;code&gt;public/index.html&lt;/code&gt;&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;script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key [YOUR_API_KEY]&amp;amp;libraries=places"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Step4 — Setup App.js&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Initialize Formik with empty initial values of address fields. Formik is the most popular open source form library for React.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step5 — Create source and destination address field with multiple way-points&lt;/strong&gt;&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The &lt;code&gt;GoogleAutocomplete&lt;/code&gt; field used is a custom google places autocomplete. You can find it &lt;a href="https://github.com/anlisha-maharjan/react-google-directions-service/blob/master/src/components/autocomplete.js" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step6 — Configure Request to Direction Service&lt;/strong&gt;&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;On line 9, an instance of the DirectionsService Object is created.&lt;br&gt;&lt;br&gt;
On line 13, the route() called takes directions request JavaScript object (with required query parameters &lt;code&gt;origin&lt;/code&gt;, &lt;code&gt;destination&lt;/code&gt; and &lt;code&gt;travelMode&lt;/code&gt;) as an argument. Also &lt;code&gt;waypoints&lt;/code&gt; parameter is included to consider all the stops between origin and destination.&lt;/p&gt;

&lt;p&gt;The second argument of route() method which is a response callback function returns &lt;code&gt;directionsResult&lt;/code&gt; and &lt;code&gt;directionsStatus&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;And that concludes it!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Source Code!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The full source code is available here — &lt;a href="https://github.com/anlisha-maharjan/react-google-directions-service" rel="noopener noreferrer"&gt;https://github.com/anlisha-maharjan/react-google-directions-service&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy Learning! Feel free to give this article a clap and follow to stay up to date with more articles!&lt;/p&gt;

&lt;p&gt;The post &lt;a href="https://anlisha.com.np/blog/google-maps-api-directions-service-in-react-plot-efficient-route-on-map-with-total-distance-and-duration/" rel="noopener noreferrer"&gt;Google Maps API Directions Service in React – Plot efficient route on map with total distance and duration.&lt;/a&gt; first appeared on &lt;a href="https://anlisha.com.np/blog" rel="noopener noreferrer"&gt;Anlisha Maharjan&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>react</category>
    </item>
    <item>
      <title>An Introduction to Absolute Imports in React Native</title>
      <dc:creator>Anlisha Maharjan</dc:creator>
      <pubDate>Mon, 08 Aug 2022 04:15:00 +0000</pubDate>
      <link>https://forem.com/anlishamaharjan/an-introduction-to-absolute-imports-in-react-native-5dn5</link>
      <guid>https://forem.com/anlishamaharjan/an-introduction-to-absolute-imports-in-react-native-5dn5</guid>
      <description>&lt;p&gt;React Native Absolute imports — made easy for beginners.&lt;/p&gt;

&lt;p&gt;Absolute imports help to simplify the paths and better organize the project as it grows. Also with absolute imports, it’s easier to copy-paste the code with imports into another file in the project and not have to tinker with import paths. &lt;/p&gt;

&lt;p&gt;When the project’s folder structure is complex, we are going to have long relative imports in the project 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 Input from ‘../../../components/form/input’;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It can be pretty hard to refactor and looks messy. The solution is to convert relative imports to absolute imports.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1 — Install&lt;/strong&gt; &lt;code&gt;babel-plugin-module-resolver&lt;/code&gt; &lt;strong&gt;plugin&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;$ npm install --save-dev babel-plugin-module-resolver
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or&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 --dev babel-plugin-module-resolver
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2 — Update&lt;/strong&gt; &lt;code&gt;babel.config.js&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Add the following code snippet in &lt;code&gt;babel.config.js&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
  plugins: [
    [
      'module-resolver',
      {
        alias: {
          '@app': './src',
        },
      },
    ],
  ],
}

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

&lt;/div&gt;



&lt;p&gt;Note: &lt;code&gt;@app&lt;/code&gt; is an alias one can give whatever one wants.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3 — Setup&lt;/strong&gt; &lt;code&gt;jsconfig.json&lt;/code&gt; &lt;strong&gt;or&lt;/strong&gt; &lt;code&gt;tsconfig.json&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using JavaScript&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create/open &lt;code&gt;jsconfig.json&lt;/code&gt; file (in the root directory of the project) and add &lt;code&gt;baseUrl&lt;/code&gt; and &lt;code&gt;paths&lt;/code&gt; setting inside &lt;code&gt;compilerOptions&lt;/code&gt; as shown in the snippet below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "compilerOptions": {
    "baseUrl": ".",
    "paths" : {
      "@app/*": ["src/*"]
    }
  }
}

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Using TypeScript&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you’re using TypeScript in React Native project, update &lt;code&gt;tsconfig.json&lt;/code&gt; file (in the root directory of the project) and add the same setting inside &lt;code&gt;compilerOptions&lt;/code&gt; as JavaScript.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "compilerOptions": {
    "baseUrl": ".",
    "paths" : {
      "@app/*": ["src/*"]
    }
  }
}

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4 — Implement Absolute Import&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Absolute imports setting is now successfully configured with &lt;code&gt;src&lt;/code&gt; folder as a custom base directory and we can import an input component located at &lt;code&gt;src/components/form/input.js&lt;/code&gt; from like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Input from '@app/components/form/input';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Happy Learning! Feel free to give this article a clap and follow to stay up to date with more articles!&lt;/p&gt;

&lt;p&gt;The post &lt;a href="https://anlisha.com.np/blog/an-introduction-to-absolute-imports-in-react-native/" rel="noopener noreferrer"&gt;An Introduction to Absolute Imports in React Native&lt;/a&gt; first appeared on &lt;a href="https://anlisha.com.np/blog" rel="noopener noreferrer"&gt;Anlisha Maharjan&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>reactnative</category>
    </item>
    <item>
      <title>Build a custom time picker React component</title>
      <dc:creator>Anlisha Maharjan</dc:creator>
      <pubDate>Thu, 30 Jun 2022 17:17:01 +0000</pubDate>
      <link>https://forem.com/anlishamaharjan/build-a-custom-time-picker-react-component-2n3b</link>
      <guid>https://forem.com/anlishamaharjan/build-a-custom-time-picker-react-component-2n3b</guid>
      <description>&lt;p&gt;In this article, we’ll create a custom time picker component combining react-datetime and react-input-mask packages.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Step1 — Start Basic CRA&lt;/strong&gt;
&lt;/h3&gt;



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

&lt;/div&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Step2 — Install react-datetime and react-input-mask packages&lt;/strong&gt;
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd axon
npm i react-datetime react-input-mask moment
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Step3 — Setup time picker component&lt;/strong&gt;
&lt;/h3&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Step4 — Style time picker component&lt;/strong&gt;
&lt;/h3&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h3&gt;
  
  
  &lt;strong&gt;Step5 — Import CustomTimePicker component in App.js&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from "react";
import CustomTimePicker from "./custom-time-picker";
import './custom-time-picker.scss';
function App() {
  return (
    &amp;lt;div
      style={{
        display: "flex",
        flexDirection: "column",
        justifyContent: "center",
        alignItems: "center",
        width: "100vw",
        height: "100vh",
      }}
    &amp;gt;
      &amp;lt;CustomTimePicker name="time" label="Time" /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;And that’s it!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The post &lt;a href="https://anlisha.com.np/blog/build-a-custom-time-picker-react-component/" rel="noopener noreferrer"&gt;Build a custom time picker React component&lt;/a&gt; first appeared on &lt;a href="https://anlisha.com.np/blog" rel="noopener noreferrer"&gt;Anlisha Maharjan&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>react</category>
      <category>timepicker</category>
    </item>
    <item>
      <title>LinkedIn API — OAuth 2.0 Access Token</title>
      <dc:creator>Anlisha Maharjan</dc:creator>
      <pubDate>Fri, 22 Apr 2022 04:15:00 +0000</pubDate>
      <link>https://forem.com/anlishamaharjan/linkedin-api-oauth-20-access-token-clc</link>
      <guid>https://forem.com/anlishamaharjan/linkedin-api-oauth-20-access-token-clc</guid>
      <description>&lt;p&gt;Hi, on a recently worked project, we needed to fetch shares (posts) of company in LinkedIn. Thus, I write this step by step guide to access LinkedIn API.&lt;/p&gt;

&lt;p&gt;The LinkedIn API uses OAuth 2.0 for user authorization and API authentication. Since we need access to Marketing APIs to fetch posts of company, we’ll follow Authorization Code Flow (3-legged authorization).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1 — Register application in the LinkedIn Developer Portal&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create a new app in &lt;a href="https://www.linkedin.com/developers/apps/new" rel="noopener noreferrer"&gt;&lt;em&gt;Developer Portal&lt;/em&gt;&lt;/a&gt;, specify App name, enter the LinkedIn Page of the company which will be associated with the application, upload logo and publish.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: It is required to associate the app with a LinkedIn Company Page. The company selected will function as the publisher of the app.&lt;/em&gt;&lt;/p&gt;

&lt;p&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%2F7sos4qf73ly7p2z2xgvc.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%2F7sos4qf73ly7p2z2xgvc.png" width="700" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2 — Request Application Verification&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Go to &lt;em&gt;Settings&lt;/em&gt; tab, select &lt;em&gt;Verify&lt;/em&gt; button next to the company associated with the app. Click the &lt;em&gt;Generate URL&lt;/em&gt; button in the Company Verification pop-up. Copy the URL and send it to the Page admin for verification.&lt;/p&gt;

&lt;p&gt;Page admin has 30 days to verify the app with the unique URL. Once the Page admin approves the request, the app will show &lt;em&gt;Verified&lt;/em&gt; in &lt;em&gt;Settings&lt;/em&gt; tab. The link will only expire earlier than 30 days if Page admin clicks &lt;em&gt;Deny&lt;/em&gt; in the request.&lt;/p&gt;

&lt;p&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%2Fst2y1ecxzaxxk1a4q6r2.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%2Fst2y1ecxzaxxk1a4q6r2.png" width="700" height="422"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&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%2F59c0aq7mj7jteb0o812n.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%2F59c0aq7mj7jteb0o812n.png" width="700" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3— Verify Application Request&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As a Page admin when a unique URL is received requesting approval to associate the app with company Page; Clicking the URL will navigate to the Developer Portal. Sign in and the landing page will feature the request details; company page information, app information, and the requestor’s name. The request can either be approved or denied.&lt;/p&gt;

&lt;p&gt;Once verification is complete, it cannot be undone. If the link is accessed after 30 days, the landing page will showcase an expired message and a new unique URL link must be generated.&lt;/p&gt;

&lt;p&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%2Fgu3u7tp8kmx2e3xjx4ta.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%2Fgu3u7tp8kmx2e3xjx4ta.png" width="700" height="356"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4— Application Credentials and Redirect URL&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Next click the &lt;em&gt;Auth&lt;/em&gt; tab to view application credentials i.e &lt;em&gt;Client ID&lt;/em&gt; and &lt;em&gt;Client Secret&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Under &lt;em&gt;OAuth 2.0 settings, _we need to specify _Authorized redirect URLs&lt;/em&gt;. Since we’re using Postman to get access token, we’ll add the Postman callback URL ‘&lt;em&gt;&lt;a href="https://oauth.pstmn.io/v1/callback" rel="noopener noreferrer"&gt;https://oauth.pstmn.io/v1/callback&lt;/a&gt;&lt;/em&gt;’ to the list.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: Please note Client ID&lt;/em&gt; and &lt;em&gt;Client Secret for later use.&lt;/em&gt;&lt;/p&gt;

&lt;p&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%2Fuu5gvij7eyvcfkian302.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%2Fuu5gvij7eyvcfkian302.png" width="700" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5— Setup OAuth 2.0 scopes&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To fetch data through LinkedIn API we requires access to proper OAuth 2.0 scopes such as &lt;code&gt;r_basicprofile&lt;/code&gt;, &lt;code&gt;r_organization_social&lt;/code&gt;. These scopes are based on the products added in the application.&lt;/p&gt;

&lt;p&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%2Fskdjwlffi3qykhssn5th.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%2Fskdjwlffi3qykhssn5th.png" width="700" height="266"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click the &lt;em&gt;Products&lt;/em&gt; tab and apply to &lt;em&gt;Marketing Developer Platform&lt;/em&gt;, &lt;em&gt;Share on LinkedIn&lt;/em&gt; and &lt;em&gt;Sign in with LinkedIn&lt;/em&gt;.&lt;/p&gt;

&lt;p&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%2Foyjfinqnaf2z77rp1xyd.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%2Foyjfinqnaf2z77rp1xyd.png" width="700" height="356"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Complete the &lt;em&gt;MDP&lt;/em&gt; access form under &lt;em&gt;Products &amp;gt; Marketing Developer Platform&lt;/em&gt;. A confirmation email is received when the application has been reviewed.&lt;/p&gt;

&lt;p&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%2Fsk3f5y6nnksm68hx7azl.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%2Fsk3f5y6nnksm68hx7azl.png" width="700" height="356"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Check the OAuth 2.0 scopes for the application now that products are added. &lt;em&gt;Sign in with LinkedIn&lt;/em&gt; product gives access to &lt;code&gt;r_liteprofile&lt;/code&gt; and &lt;code&gt;r_emailaddress&lt;/code&gt; scopes. &lt;em&gt;Share on LinkedIn&lt;/em&gt; product gives access to &lt;code&gt;w_member_social&lt;/code&gt; scope. Remaining scopes are obtained from &lt;em&gt;Marketing Developer Platform _product&lt;/em&gt;._&lt;/p&gt;

&lt;p&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%2Fqavy1f9gu90g0g1u22cy.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%2Fqavy1f9gu90g0g1u22cy.png" width="700" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6— Get Access Token via Postman&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Open &lt;em&gt;Postman, _Create _New Request _and&lt;/em&gt; &lt;em&gt;Click _Authorization&lt;/em&gt; Tab. Select &lt;em&gt;Type&lt;/em&gt; as &lt;em&gt;OAuth 2.0&lt;/em&gt;. Fill in the given details:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Token Name : &lt;code&gt;{provide token name}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Grant Type : &lt;code&gt;Authorization Code&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Callback URL: &lt;code&gt;https://oauth.pstmn.io/v1/callback&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Auth URL : &lt;code&gt;https://www.linkedin.com/oauth/v2/authorization&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Access Token URL : &lt;code&gt;https://www.linkedin.com/oauth/v2/accessToken&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Client ID : &lt;code&gt;{provide Client ID}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Client Secret : &lt;code&gt;{provide Client Secret}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Scope : &lt;code&gt;r_basicprofile, r_liteprofile, r_emailaddress, w_member_social, r_organization_social, rw_organization_admin, w_organization_social&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;State : &lt;code&gt;{provide a unique string value}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Client Authentication: &lt;code&gt;Send client credentials in body&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&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%2Fxmvzscmih12yobc4uzc4.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%2Fxmvzscmih12yobc4uzc4.png" width="700" height="461"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on &lt;em&gt;Get New Access Token. _Postman will take us to the LinkedIn authorization page, where it is prompted to log into LinkedIn. Click _Allow&lt;/em&gt; to authorize the request. The prompt on the authorization page is dictated by the requested scopes in the previous step.&lt;/p&gt;

&lt;p&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%2Fx4fftbag3ecq2t6r9qgw.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%2Fx4fftbag3ecq2t6r9qgw.png" width="421" height="693"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Postman will display the access token to be used for testing. Choose &lt;em&gt;Use Token&lt;/em&gt; button to set this token.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 7— LinkedIn Find Shares By Owner API&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Our application can now retrieve the collection of shares (posts) owned by a specific organization for which the authenticated member is an &lt;em&gt;Admin&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;API Endpoint:&lt;/p&gt;

&lt;p&gt;GET &lt;code&gt;https://api.linkedin.com/v2/shares?q=owners&amp;amp;owners=urn:li:company:{id}&amp;amp;sortBy=LAST_MODIFIED&amp;amp;sharesPerOwner=1000&amp;amp;count=50&amp;amp;start=0&amp;amp;oauth2_access_token={ACCESS_TOKEN}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;LinkedIn Company ID is a unique 6 to 9 digits long string of numbers. To find Company ID as a LinkedIn Page Admin, navigate to the Admin View of the LinkedIn Page from the All Pages or Home tab. The LinkedIn company ID is the numbers after “/company/” in the URL. For example, if the Admin URL for the LinkedIn Page is &lt;code&gt;https://www.linkedin.com/company/8681905/admin/&lt;/code&gt;, the company ID is &lt;code&gt;8681905&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;And this is it!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you need to fetch shares (posts) of LinkedIn Company Page that doesn’t belong to you, then the Admin of that Company Page must add you as &lt;em&gt;Content admin&lt;/em&gt; role. Skip these steps if not required.&lt;/p&gt;

&lt;p&gt;As a Page Admin, access your LinkedIn Company Page Admin view. Click the &lt;em&gt;Admin tools&lt;/em&gt; dropdown at the top of the page and select &lt;em&gt;Manage Admins&lt;/em&gt;. Click the &lt;em&gt;Add admin&lt;/em&gt; button. Search the authenticated member and assign role as &lt;em&gt;Content admin&lt;/em&gt; and Save.&lt;/p&gt;

&lt;p&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%2F0k07zt1txjb5ekldh871.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%2F0k07zt1txjb5ekldh871.png" width="700" height="331"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&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%2Fpopxetkkxnrrk90nsr4a.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%2Fpopxetkkxnrrk90nsr4a.png" width="540" height="468"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dependencies:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For each company, the authenticated user must have a &lt;em&gt;Admin&lt;/em&gt; role in the company’s LinkedIn Page to fetch shares (posts) of the organization.&lt;/li&gt;
&lt;li&gt;The app must have access to &lt;em&gt;Marketing Developer Platform&lt;/em&gt; product and its scopes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;References:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.microsoft.com/en-us/linkedin/shared/authentication/getting-access" rel="noopener noreferrer"&gt;Getting Access to LinkedIn APIs – LinkedInThe LinkedIn API uses OAuth 2.0 for user authorization and API authentication. Applications must be authorized and…docs.microsoft.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you enjoyed learning about LinkedIn API access flow then feel free to give this article a clap and follow to stay up to date with more articles! Thanks for reading!&lt;/p&gt;

&lt;p&gt;The post &lt;a href="https://anlisha.com.np/blog/linkedin-api-oauth-2-0-access-token/" rel="noopener noreferrer"&gt;LinkedIn API — OAuth 2.0 Access Token&lt;/a&gt; first appeared on &lt;a href="https://anlisha.com.np/blog" rel="noopener noreferrer"&gt;Anlisha Maharjan&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>linkedin</category>
    </item>
    <item>
      <title>Tailwind CSS in HTML starter via NPM</title>
      <dc:creator>Anlisha Maharjan</dc:creator>
      <pubDate>Mon, 28 Mar 2022 04:15:00 +0000</pubDate>
      <link>https://forem.com/anlishamaharjan/tailwind-css-in-html-starter-via-npm-3795</link>
      <guid>https://forem.com/anlishamaharjan/tailwind-css-in-html-starter-via-npm-3795</guid>
      <description>&lt;p&gt;Tailwind CSS is a utility-first CSS framework. This article includes steps to install Tailwind CSS in HTML via package manager and how to properly process Tailwind CSS. Although it requires a bit more setup, it is definitely the best way to make use of all of the features that Tailwind CSS can provide.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1 — Initialize package.json&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;npm init -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note: The -y flag will say yes to all questions&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2— Install Tailwind CSS&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;npm install -D tailwindcss@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;-D option if to save package to peerDependencies&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3— Include Tailwind CSS directives&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now that Tailwind CSS is installed, the next step is creating a &lt;code&gt;tailwind.css&lt;/code&gt; file and add the following code to inject the Tailwind CSS directives.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@tailwind base;
@tailwind components;
@tailwind utilities;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4— Setup Tailwind configuration file&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The configuration file makes it easy to customize the classes in Tailwind CSS by changing any fonts, color, spacing, etc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx tailwindcss init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A minimal configuration file named &lt;code&gt;tailwind.config.js&lt;/code&gt; is generated.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
 content: ["./index.html"], // Paths to all template files
 theme: {
  extend: {},
 },
 plugins: [],
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 5— Processing Tailwind CSS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We’ll be using TailwindCSS CLI to build the CSS. In the following command &lt;code&gt;./assets/scss/tailwind.css&lt;/code&gt; is the input, and the built-css output will be placed in &lt;code&gt;./assets/css/tailwind.css&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx tailwindcss -i ./assets/scss/tailwind.css -o ./assets/css/tailwind.css --watch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also we can add the following script into &lt;code&gt;package.json&lt;/code&gt; to easily build CSS with command &lt;code&gt;npm run dev&lt;/code&gt; .&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
"dev": "tailwindcss -i ./assets/scss/tailwind.css -o ./assets/css/tailwind.css --watch",
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 6— Link Tailwind CSS into HTML&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create an &lt;code&gt;index.html&lt;/code&gt; file; Add the following code in HTML template head section.&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;!-- index.html --&amp;gt;
&amp;lt;link rel="stylesheet" href="./assets/css/tailwind.css" /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;And This is it. Enjoy!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The post &lt;a href="https://anlisha.com.np/blog/tailwind-css-in-html-starter-via-npm/" rel="noopener noreferrer"&gt;Tailwind CSS in HTML starter via NPM&lt;/a&gt; first appeared on &lt;a href="https://anlisha.com.np/blog" rel="noopener noreferrer"&gt;Anlisha Maharjan&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>tailwindcss</category>
    </item>
    <item>
      <title>Fabric.js in React — Draw bounding box in webcam preview using canvas events.</title>
      <dc:creator>Anlisha Maharjan</dc:creator>
      <pubDate>Tue, 15 Mar 2022 16:15:00 +0000</pubDate>
      <link>https://forem.com/anlishamaharjan/fabricjs-in-react-draw-bounding-box-in-webcam-preview-using-canvas-events-1i5f</link>
      <guid>https://forem.com/anlishamaharjan/fabricjs-in-react-draw-bounding-box-in-webcam-preview-using-canvas-events-1i5f</guid>
      <description>&lt;p&gt;Fabric.js is a JavaScript library for HTML5 canvas. Using Fabric.js one can create object/shapes on canvas. We’ll be incorporating canvas events to draw bounding box over webcam component.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step1 — Install Fabric.js &amp;amp; react-html5-camera-photo&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;npm i fabric react-html5-camera-photo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step2 — Create canvas &amp;amp; camera element&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;&amp;lt;Camera onTakePhoto={(uri) =&amp;gt; {}} /&amp;gt;
&amp;lt;canvas id="fabricEl" width="720" height="348"&amp;gt;&amp;lt;/canvas&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step3 — Initialize fabric.Canvas&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;import React, { useEffect, useState } from "react";
import Camera from "react-html5-camera-photo";
import { fabric } from "fabric";

const [canvas, setCanvas] = useState("");

const initCanvas = () =&amp;gt;
 new fabric.Canvas("fabricEl", {
  selection: false,
  stateful: true,
});

useEffect(() =&amp;gt; {
 setCanvas(initCanvas());
}, []);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that &lt;code&gt;initCanvas&lt;/code&gt; function returns a fabric.Canvas object; invoked upon initial rendering of the DOM.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step4 — Draw bounding box with canvas mouse events&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Fabric supports a number of events to allow for interactivity and extensibility. In order to subscribe to events for a canvas we use the &lt;code&gt;on&lt;/code&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;useEffect(() =&amp;gt; {
 if (canvas) {
  var rectangle;
  canvas.on("mouse:down", function (e) {
    var pointer = canvas.getPointer(e.e);
    rectangle = new fabric.Rect({
     id: 1,
     top: pointer.y,
     left: pointer.x,
     width: 0,
     height: 0,
     originX: "left",
     originY: "top",
     fill: "rgba(255,0,0,0.3)",
     stroke: "rgba(255,0,0,1)",
     strokeWidth: 2,
     hasControls: true,
     hasRotatingPoint: true,
     hasBorders: true,
     transparentCorners: false,
     selectable: true,
     cornerSize: 10,
     cornerColor: "rgba(255,0,0,1)",
     borderColor: "rgba(255,0,0,1)",
     cornerStrokeColor: "rgba(255,0,0,1)",
     cornerStyle: "rect",
    });
    canvas.add(rectangle);
  });
 }
}, [canvas]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On &lt;code&gt;mouse:down&lt;/code&gt; event of canvas we create a &lt;code&gt;fabric.Rect&lt;/code&gt; object and add it to the canvas via &lt;code&gt;canvas.add()&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Final Code!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;View the code on &lt;a href="https://gist.github.com/anlisha-maharjan/187755ed07a75f39074cb2aad83275d8" rel="noopener noreferrer"&gt;Gist&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Note on line 95, &lt;code&gt;canvas.renderAll()&lt;/code&gt; re-renders both the upper and lower canvas layers on the DOM. The &lt;code&gt;object:moving&lt;/code&gt; event is to restrict the bounding box rectangle within canvas boundary. The &lt;code&gt;object:modified&lt;/code&gt; event calculates bounding box center x, center y, width and height.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Demo!&lt;/strong&gt;&lt;/p&gt;

&lt;p&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%2Fshppbaeisv97x17zhyio.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%2Fshppbaeisv97x17zhyio.png" width="700" height="393"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The post &lt;a href="https://anlisha.com.np/blog/fabric-js-in-react-draw-bounding-box-in-webcam-preview-using-canvas-events/" rel="noopener noreferrer"&gt;Fabric.js in React — Draw bounding box in webcam preview using canvas events.&lt;/a&gt; first appeared on &lt;a href="https://anlisha.com.np/blog" rel="noopener noreferrer"&gt;Anlisha Maharjan&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>react</category>
    </item>
    <item>
      <title>Automating Internationalization with Google Spreadsheet and i18next.</title>
      <dc:creator>Anlisha Maharjan</dc:creator>
      <pubDate>Tue, 01 Mar 2022 16:15:00 +0000</pubDate>
      <link>https://forem.com/anlishamaharjan/automating-internationalization-with-google-spreadsheet-and-i18next-2kbk</link>
      <guid>https://forem.com/anlishamaharjan/automating-internationalization-with-google-spreadsheet-and-i18next-2kbk</guid>
      <description>&lt;p&gt;The article is for the front-end developers who are suffering from the manual “copy-and-paste” internationalization process. Through this guide executing a single line of script shall automate the entire process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use Case&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;React app that supports multiple languages (with i18next and react-i18next library)&lt;/li&gt;
&lt;li&gt;Setup Google Spreadsheet as JSON Hosting + v4 Google sheet API authentication&lt;/li&gt;
&lt;li&gt;Script that auto synchronize translations between Google Spreadsheet &amp;amp; JSON file (with google-spreadsheet library &amp;amp; Google Sheets API) by given two methods:
– Scanning the &lt;code&gt;key&lt;/code&gt; from the source code and uploading the scanned &lt;code&gt;key&lt;/code&gt; to Google spreadsheet.
– Downloading the translated strings from Google spreadsheet when building the source code.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Let’s Start&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1 — Install and configure i18next &amp;amp; react-i18next library&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;npx create-react-app react-internationalization
cd react-internationalization
npm install @mui/material @emotion/react @emotion/styled
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This will create a basic CRA. We also installed MUI 5 for creating UI components.&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 i18next react-i18next i18next-browser-languagedetector i18next-http-backend
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This will install i18next framework and its React wrapper.&lt;/p&gt;

&lt;p&gt;Next create a file &lt;em&gt;i18n.js&lt;/em&gt; at the top level of the project with given configuration below:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;Then import the file in &lt;em&gt;index.js&lt;/em&gt; as shown below:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;All translations goes into — _public/locales _— with a separate JSON file for each supported language.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;├── public/
│ ├── locales/
│ ├── en/
| ├── translation.json
|
│ ├── no
| ├── translation.json
|
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Also place the snippet below in &lt;em&gt;App.js&lt;/em&gt; for UI components that reflects switch between multiple languages.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2 — Setup Google Spreadsheet&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create a Google Sheet with the following structure:&lt;/p&gt;

&lt;p&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%2Fz0g0jfkjd72grqcf0nkg.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%2Fz0g0jfkjd72grqcf0nkg.png" width="800" height="160"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note the spreadsheet id.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1B1njd441X7di47joj9OvQGuJZ-mR9yFQrpr0WNW6c94
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;To handle v4 Google sheet API authentication follow &lt;a href="https://theoephraim.github.io/node-google-spreadsheet/#/getting-started/authentication?id=service-account" rel="noopener noreferrer"&gt;service account option&lt;/a&gt;. Generated JSON file as shown below; &lt;em&gt;secret.json&lt;/em&gt; is kept at the top level of the project and add it to .gitignore!&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "type": "service_account",
  "project_id": "XXXXXXXXXXXXXXX",
  "private_key_id": "XXXXXXXXXXXXXXX",
  "private_key": "XXXXXXXXXXXXXXX",
  "client_email": "service-account-google-sheet-a@XXXXXXXXXXXX.iam.gserviceaccount.com",
  "client_id": "XXXXXXXXXXXXXXX",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/service-account-google-sheet-XXXXXXXXXXXXX.iam.gserviceaccount.com"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Step 3 — Automated script to synchronize translations between Google Spreadsheet &amp;amp; JSON file&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;google-spreadsheet is a wrapper library that lets you use the Google Sheets API. It can be used to create a new sheet or to read, write, and manage cells and rows.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i google-spreadsheet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Create &lt;em&gt;fetch-google-spreadsheet.js&lt;/em&gt; and &lt;em&gt;push-google-spreadsheet.js&lt;/em&gt; file at the top level of the project and insert the below code in it.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;




&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Insert scripts in &lt;em&gt;package.json&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;{
"start": "npm run fetch:i18n &amp;amp;&amp;amp; react-scripts start",
"build": "npm run fetch:i18n &amp;amp;&amp;amp; react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"push:i18n": "node push-google-spreadsheet.js",
"fetch:i18n": "node fetch-google-spreadsheet.js"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Developer: Run &lt;code&gt;npm run push:i18n&lt;/code&gt; then request translation.&lt;/li&gt;
&lt;li&gt;Translator: Enter translations in the spreadsheet&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is it. Every time you build/start application, the &lt;code&gt;npm run fetch:i18n&lt;/code&gt; will be executed and the most recent translation will be applied to the build. I hope this helps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Source Code!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The full source code is available here — &lt;a href="https://github.com/anlisha-maharjan/react-internationalization-googlespreadsheet-i18next" rel="noopener noreferrer"&gt;https://github.com/anlisha-maharjan/react-internationalization-googlespreadsheet-i18next&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;More info!&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://www.i18next.com/overview/configuration-options" rel="noopener noreferrer"&gt;List of all config options available for i18next_._&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://theoephraim.github.io/node-google-spreadsheet/#/getting-started/authentication?id=service-account" rel="noopener noreferrer"&gt;v4 google sheets API Authentication using service account.&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The post &lt;a href="https://anlisha.com.np/blog/automating-internationalization-with-google-spreadsheet-and-i18next/" rel="noopener noreferrer"&gt;Automating Internationalization with Google Spreadsheet and i18next.&lt;/a&gt; first appeared on &lt;a href="https://anlisha.com.np/blog" rel="noopener noreferrer"&gt;Anlisha Maharjan&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>react</category>
    </item>
    <item>
      <title>Integrate Jitsi Meet IFrame API in React</title>
      <dc:creator>Anlisha Maharjan</dc:creator>
      <pubDate>Sun, 13 Feb 2022 16:15:00 +0000</pubDate>
      <link>https://forem.com/anlishamaharjan/integrate-jitsi-meet-iframe-api-in-react-84b</link>
      <guid>https://forem.com/anlishamaharjan/integrate-jitsi-meet-iframe-api-in-react-84b</guid>
      <description>&lt;p&gt;Jitsi is a set of open-source projects that allows you to easily build and deploy secure videoconferencing solutions.&lt;br&gt;&lt;br&gt;
We’ll be using IFrame API to embed Jitsi Meet functionality in React application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A peak at final UI!&lt;/strong&gt;&lt;/p&gt;

&lt;p&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%2Fkyu81mbnymp8e71w6eis.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%2Fkyu81mbnymp8e71w6eis.png" width="700" height="343"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let’s Start!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step1 — Start Basic CRA&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;npx create-react-app react-jitsi-meet
cd react-jitsi-meet
npm install @mui/material @emotion/react @emotion/styled
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We also installed MUI 5 for creating UI components.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2 — Setup Jitsi component; Initialize Jitsi Meet API library scripts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A container element with pre-defined height and width is must for Jitsi iframe to render into.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;If you have self-hosted Jitsi server in your domain, you can specify its URL endpoint instead of &lt;code&gt;meet.jit.si.&lt;/code&gt;&lt;br&gt;&lt;br&gt;
Note that&lt;code&gt;initialise&lt;/code&gt; function is called only once when the component is first rendered, and Jitsi’s &lt;code&gt;dispose()&lt;/code&gt; method is called when the component is destroyed.&lt;br&gt;&lt;br&gt;
Also the object from instantiating &lt;code&gt;JitsiMeetExternalAPI&lt;/code&gt; provides methods and event listeners to configure and control the Jitsi interface. For example: &lt;code&gt;interfaceConfigOverwrite&lt;/code&gt; allows to overrides options such as &lt;code&gt;APP_NAME&lt;/code&gt;, &lt;code&gt;DEFAULT_BACKGROUND&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3— Import Jisti Component in App.js&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;import React from “react”;
import Jitsi from “./components/jitsi”;
function App() {
  return &amp;lt;Jitsi uuid=”1be9b511-eb38–4a97–909b-d70ee03a9501" /&amp;gt;;
}
export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;This is it.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Source Code!&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
all the source code is available at — &lt;a href="https://github.com/anlisha-maharjan/react-jitsi-meet" rel="noopener noreferrer"&gt;https://github.com/anlisha-maharjan/react-jitsi-meet&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;More Info!&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
 &lt;a href="https://jitsi.github.io/handbook/docs/dev-guide/dev-guide-iframe" rel="noopener noreferrer"&gt;Have a look at Jitsi’s docs for all the options, commands, methods and events available.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The post &lt;a href="https://anlisha.com.np/blog/integrate-jitsi-meet-iframe-api-in-react/" rel="noopener noreferrer"&gt;Integrate Jitsi Meet IFrame API in React&lt;/a&gt; first appeared on &lt;a href="https://anlisha.com.np/blog" rel="noopener noreferrer"&gt;Anlisha Maharjan&lt;/a&gt;.&lt;/p&gt;

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