<?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: Wilmela</title>
    <description>The latest articles on DEV Community by Wilmela (@wilmela).</description>
    <link>https://dev.to/wilmela</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%2F661444%2F3108f420-19c0-4b42-bf89-1c2183cadb35.png</url>
      <title>DEV Community: Wilmela</title>
      <link>https://dev.to/wilmela</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/wilmela"/>
    <language>en</language>
    <item>
      <title>Safely Updating Your Deployed Next.js App on a DigitalOcean Droplet.</title>
      <dc:creator>Wilmela</dc:creator>
      <pubDate>Thu, 11 Jul 2024 12:15:08 +0000</pubDate>
      <link>https://dev.to/wilmela/safely-updating-your-deployed-nextjs-app-on-a-digitalocean-droplet-1agd</link>
      <guid>https://dev.to/wilmela/safely-updating-your-deployed-nextjs-app-on-a-digitalocean-droplet-1agd</guid>
      <description>&lt;h2&gt;
  
  
  Introduction:
&lt;/h2&gt;

&lt;p&gt;This article assumes you've already taken the exciting first step of deploying your Next.js application to a DigitalOcean droplet. Congratulations on that achievement! Now, as you continue to refine and enhance your app, you'll need to know how to update it safely and efficiently. This guide is tailored for beginners who are looking for a reliable way to update their live application without causing extended downtime or risking data loss.&lt;/p&gt;

&lt;p&gt;Let's begin.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Access Your Droplet&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use SSH via terminal or connect through the DigitalOcean console.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Navigate to Your App Directory&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Run: &lt;code&gt;cd /var/www/&amp;lt;app name&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Check Running Processes&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Execute: &lt;code&gt;pm2 list&lt;/code&gt; to view active apps and their IDs&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Stop and Delete the Current Process&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Run: &lt;code&gt;pm2 stop &amp;lt;id&amp;gt;&lt;/code&gt;followed by &lt;code&gt;pm2 delete &amp;lt;index&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Remove the Existing App Folder&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Navigate up one level: &lt;code&gt;cd ..&lt;/code&gt;&lt;br&gt;
Delete the app folder: &lt;code&gt;rm -rf &amp;lt;app name&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Clone the Updated Repository&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use: &lt;code&gt;git clone &amp;lt;repo-url&amp;gt;&lt;/code&gt;&lt;br&gt;
You'll need to enter your GitHub credentials&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Enter the New App Directory&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Run: &lt;code&gt;cd &amp;lt;app name&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Update Environment Variables (if applicable)&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Edit the production environment file: &lt;code&gt;nano .env.production&lt;/code&gt;&lt;br&gt;
Update variables as needed&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Install Sharp for Image Processing&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Run: &lt;code&gt;npm i sharp&lt;/code&gt; if not needed Run &lt;code&gt;npm install or yarn&lt;/code&gt; to install all dependencies.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Build Your Updated App&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Execute: &lt;code&gt;npm run build or yarn build&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Ensure PM2 is Installed Globally&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Run: &lt;code&gt;npm i -g pm2&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Start Your App with PM2&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use: &lt;code&gt;pm2 start npm --name "&amp;lt;app name&amp;gt;" -- start&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Save the PM2 Process List&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Execute: &lt;code&gt;pm2 save&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Set Up PM2 to Start on System Boot&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Run: &lt;code&gt;pm2 startup&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Return to the Root Directory&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Simply type: &lt;code&gt;cd&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Restart Nginx&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Run: &lt;code&gt;sudo service nginx restart&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;Updating your Next.js application on a DigitalOcean droplet doesn't have to be a nerve-wracking experience. By following these steps, you can safely and efficiently update your live application with minimal downtime. This process ensures that you're working with the latest version of your code while maintaining a stable production environment.&lt;br&gt;
Remember, practice makes perfect. The more you perform these updates, the more comfortable and proficient you'll become with the process. Happy coding, and here's to your continued success in the world of Next.js and DigitalOcean!&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary:
&lt;/h2&gt;

&lt;p&gt;This guide outlines a 16-step process for updating a Next.js application on a DigitalOcean droplet. The steps include accessing the droplet, stopping the current app, removing old files, cloning the updated repo, rebuilding the app, and restarting the necessary services. By following this method, developers can ensure a smooth and safe update process for their live applications.&lt;/p&gt;

</description>
      <category>node</category>
      <category>beginners</category>
      <category>droplet</category>
      <category>react</category>
    </item>
    <item>
      <title>Integrating Express.js Server with Next.js-13: Unleash the Power of Combined Frameworks</title>
      <dc:creator>Wilmela</dc:creator>
      <pubDate>Tue, 20 Jun 2023 09:25:40 +0000</pubDate>
      <link>https://dev.to/wilmela/integrating-expressjs-server-with-nextjs-13-unleash-the-power-of-combined-frameworks-10kc</link>
      <guid>https://dev.to/wilmela/integrating-expressjs-server-with-nextjs-13-unleash-the-power-of-combined-frameworks-10kc</guid>
      <description>&lt;h2&gt;
  
  
  Introduction:
&lt;/h2&gt;

&lt;p&gt;Next.js-13 and Express.js are two powerful frameworks in the JavaScript ecosystem, each offering distinct advantages. Next.js-13 provides features like server-side rendering (SSR) and static site generation (SSG), along with an excellent developer experience. On the other hand, Express.js is known for its flexibility and robustness in building server-side applications. By combining these frameworks, developers can harness the strengths of both to create versatile web applications. In this blog post, we will explore the steps to connect an Express.js server with Next.js-13 seamlessly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefits of Next.js-13:
&lt;/h2&gt;

&lt;p&gt;Next.js-13 offers a host of advantages that contribute to its popularity among developers:&lt;/p&gt;

&lt;p&gt;Server-side rendering (SSR): Next.js-13 enables rendering React components on the server, leading to faster page loading and improved search engine optimization (SEO).&lt;br&gt;
Static site generation (SSG): It generates static HTML pages during the build process, resulting in optimal performance and reduced server load.&lt;br&gt;
Excellent developer experience: Next.js-13 provides a delightful development experience with features like automatic code splitting, hot module reloading, and built-in TypeScript support.&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefits of Express.js:
&lt;/h2&gt;

&lt;p&gt;Express.js is a widely adopted framework for building server-side applications with Node.js. Some key advantages of using Express.js include:&lt;/p&gt;

&lt;p&gt;Flexibility: Express.js takes a minimalistic, unopinionated approach, allowing developers to structure applications as per their specific needs.&lt;br&gt;
Middleware ecosystem: Express.js boasts a vast collection of middleware modules, making it easy to add additional functionality to the server.&lt;br&gt;
Robustness: With its mature and stable ecosystem, Express.js has proven to be reliable in handling various server-side tasks and managing routes efficiently.&lt;/p&gt;

&lt;h2&gt;
  
  
  Combining Next.js-13 and Express.js:
&lt;/h2&gt;

&lt;p&gt;By integrating an Express.js server with Next.js-13, developers can leverage the best of both worlds. Express.js can handle backend logic, routing, and API endpoints, while Next.js-13 takes care of rendering React components, server-side rendering, and static site generation. This powerful combination empowers developers to build dynamic web applications that benefit from the unique features offered by each framework.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps to Create Both Projects:
&lt;/h2&gt;

&lt;p&gt;First, let's create a basic express server.&lt;br&gt;
1.&lt;code&gt;mkdir exp-next &amp;amp;&amp;amp; cd exp-next&lt;/code&gt;&lt;br&gt;
2.&lt;code&gt;npm init -y&lt;/code&gt;&lt;br&gt;
3.&lt;code&gt;npm install express cors&lt;/code&gt;&lt;br&gt;
4.&lt;code&gt;mkdir src &amp;amp;&amp;amp; cd src &amp;amp;&amp;amp; touch index.js&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In the package.json file add the line "type":"module", to enable the use of "import" statement and "start": "node src/index.js" script&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%2Fbwdr8d7pw7b53l8j2bxv.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%2Fbwdr8d7pw7b53l8j2bxv.png" alt="Image description" width="721" height="686"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, in your index.js file add the following lines to create a basic express server which returns an array of users.&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%2F3b78sqbjhrlrtg4t4ku0.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%2F3b78sqbjhrlrtg4t4ku0.png" alt="Image description" width="605" height="707"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally &lt;code&gt;npm start&lt;/code&gt; to run your server. If everything is ok, you will see "App listening on port 5000!" on your console.&lt;/p&gt;

&lt;p&gt;Next, we will create out Next.js-13 app. Run the following commands on your command prompt.&lt;br&gt;
1.&lt;code&gt;mkdir next-exp &amp;amp;&amp;amp; cd next-exp&lt;/code&gt;&lt;br&gt;
2.&lt;code&gt;npx create-next-app@latest&lt;/code&gt;&lt;br&gt;
3.What is your project named? . using . will install nextjs in the current folder with the folder name next-exp&lt;br&gt;
4.Accept all default settings.&lt;br&gt;
5.&lt;code&gt;npm install --save express&lt;/code&gt;&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%2Fp0nmge5692lbyx0n7ju8.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%2Fp0nmge5692lbyx0n7ju8.png" alt="Image description" width="800" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Next.js Settings
&lt;/h2&gt;

&lt;p&gt;Open the next.config.js file and make the following changes.&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%2F32tf90y4zb9690095yva.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%2F32tf90y4zb9690095yva.png" alt="Image description" width="730" height="602"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Client component
&lt;/h2&gt;

&lt;p&gt;In the app folder, open page.tsx and add the following code.&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%2Fhkit5k5qqcfw8ljv75kq.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%2Fhkit5k5qqcfw8ljv75kq.png" alt="Image description" width="800" height="1067"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Run &lt;code&gt;npm start&lt;/code&gt; in your express project to start the server and &lt;code&gt;npm run dev&lt;/code&gt; in your next.js project.&lt;/p&gt;

&lt;p&gt;Notice we did not pass any other option to the fetch function, just the url. Nextjs by default uses fetch(url, { cache: 'force-cache' }) which automatically caches our users.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: Next.js recommends the use of SWR or React-Query for data fetching on the client side as against useEffect hook.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Server component
&lt;/h2&gt;

&lt;p&gt;In the app folder, following open page.tsx and replace the previous code with the following lines.&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%2Fjaiu63uvdxsnvpn67x21.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%2Fjaiu63uvdxsnvpn67x21.png" alt="Image description" width="800" height="1017"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here we are passing { cache: 'no-cache' } option to the fetch function to disable Next.js default behaviour and always refetch users when we make a request.&lt;/p&gt;

&lt;p&gt;That's it! Now you can enjoy all the goodies Next.js-13 has to offer while keeping your existing express.js backend.&lt;br&gt;
&lt;a href="https://github.com/Wilmela/nextjs-express" rel="noopener noreferrer"&gt;You can find the code here. &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading.&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>express</category>
      <category>react</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Using SVG in react native.</title>
      <dc:creator>Wilmela</dc:creator>
      <pubDate>Fri, 26 May 2023 18:17:46 +0000</pubDate>
      <link>https://dev.to/wilmela/using-svg-in-react-native-5a9o</link>
      <guid>https://dev.to/wilmela/using-svg-in-react-native-5a9o</guid>
      <description>&lt;p&gt;Scalable Vector Graphic (SVG) are quite common and easy to use when building web projects but unfortunately, they are not supported currently in react native by default.&lt;/p&gt;

&lt;p&gt;Hey, are you a beginner, are you having issues using SGVs or you intend to use it in your react native project? Alright, permit me to guide you in few steps.&lt;/p&gt;

&lt;p&gt;Just in case you want beautiful SGVs visit &lt;a href="//undraw.co"&gt;https://undraw.co/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's Go!&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Step 1. Create a react native project. I will be using expo. &lt;code&gt;npx create-expo-app MySvgApp&lt;/code&gt;. you can call yours whatever you want.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open your project in your code editor and run &lt;code&gt;expo install react-native-svg&lt;/code&gt;. This package will do the magic for us!.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a component and call it &lt;strong&gt;SVGWrapper&lt;/strong&gt;, then &lt;code&gt;import {SvgXml} from 'react-native-svg'&lt;/code&gt;;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Download an SVG image, click to open it, then copy everything between the svg tags and store it as a constant i.e. &lt;code&gt;const svgImg = &amp;lt;svg&amp;gt;.....&amp;lt;/svg&amp;gt;&lt;/code&gt;. Ensure to wrap the tags in a &lt;strong&gt;back-tick&lt;/strong&gt;. ``&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KEKB8N6U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8rgkp73dcpopx5dqo35h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KEKB8N6U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8rgkp73dcpopx5dqo35h.png" alt="SVGWrapper component" width="800" height="469"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: I have removed most of the svg content to keep the image simple.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;5.Create another component inside SVGWrapper and call it &lt;strong&gt;LoveIt&lt;/strong&gt;. Again, call it whatever you want, then you can immediately return &lt;code&gt;&amp;lt;SvgXml xml={svgImg} width='200px' height='200px /&amp;gt;&lt;/code&gt; as a self-closing component with the xml prop pointing to the svgImg constant also providing the width and height props.&lt;/p&gt;

&lt;p&gt;6.Finally, return &lt;strong&gt;LoveIT&lt;/strong&gt; as a self-closing component. Now our SVG image is ready to be used!.&lt;br&gt;
Go ahead and import &lt;strong&gt;SVGWrapper&lt;/strong&gt; into any component you want to use it and that's it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HXbxFdJz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fb361vfsjk8l4b46zn1w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HXbxFdJz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fb361vfsjk8l4b46zn1w.png" alt="App component" width="641" height="749"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading.&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>expo</category>
      <category>beginners</category>
      <category>svg</category>
    </item>
    <item>
      <title>Responsive And Adaptive UI</title>
      <dc:creator>Wilmela</dc:creator>
      <pubDate>Wed, 07 Jul 2021 11:08:27 +0000</pubDate>
      <link>https://dev.to/wilmela/responsive-and-adaptive-ui-491e</link>
      <guid>https://dev.to/wilmela/responsive-and-adaptive-ui-491e</guid>
      <description>&lt;p&gt;This is an absolute beginners post but would be useful if you are still switching devices one after the other to check and make corrections to your codes and also wondering how to display your screen layout based on certain conditions and screen sizes.&lt;/p&gt;

&lt;p&gt;Often times we focus on developing using one mobile phone (irrespective of OS) or emulator and forget to check how our UI will respond when we launch them in other devices perhaps smaller ones. However, if you are developing for a particular screen size then you may disregard this post but if your intention is to cover a wild range of screen sizes then this is &lt;strong&gt;CRITICAL!&lt;/strong&gt;&lt;br&gt;
Long story short... How do we achieve this  &lt;strong&gt;RESPONSIVENESS&lt;/strong&gt; in react-native?&lt;/p&gt;

&lt;p&gt;Just like we use the &lt;em&gt;media queries in css&lt;/em&gt; , we can use the &lt;em&gt;DIMENSION API combined with IF CHECKS and TERNARY OPERATORS&lt;/em&gt;. But How?!.. Alright chill... &lt;/p&gt;
&lt;h2&gt;
  
  
  Steps
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;We need to first be able to monitor our code changes using different screen sizes Live. so let's say you have a 5.7" smartphone and Expo Go installed, you can install a 3.7" android emulator from android studio... IOS developers can set up different screen sizes with XCode &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Vgt6Xgvj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5dct8507go7rmdmxve2f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Vgt6Xgvj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5dct8507go7rmdmxve2f.png" alt="emulator" width="800" height="397"&gt;&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We must know the height and width of your target devices in pixels (density-independent pixel...react-native default unit).&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;import the Dimensions Api&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;import { Dimensions } from 'react-native'&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;to enable use use the&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;Dimensions.get('window').height and Dimensions.get('window').width&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
 properties.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Combine these properties with some conditional statements to display your components, fonts, styles, margins, paddings etc to fit your monitors.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iQGuBZm4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gfssmwo1bxu7tzfegazz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iQGuBZm4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gfssmwo1bxu7tzfegazz.png" alt="if" width="476" height="106"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5pccldeA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l5khlbforpsa80g19faw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5pccldeA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l5khlbforpsa80g19faw.png" alt="ternary" width="625" height="325"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's all at the most basic level. This is quite simple and very helpful.&lt;br&gt;
&lt;strong&gt;Don't forget you can change almost anything&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading..&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>expo</category>
      <category>beginners</category>
      <category>jsx</category>
    </item>
  </channel>
</rss>
