<?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: Caleb Crosby Adainoo</title>
    <description>The latest articles on DEV Community by Caleb Crosby Adainoo (@calebcadainoo).</description>
    <link>https://dev.to/calebcadainoo</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%2F317155%2F46c4d422-d5ba-4581-93e1-998dbc7ebd8e.jpg</url>
      <title>DEV Community: Caleb Crosby Adainoo</title>
      <link>https://dev.to/calebcadainoo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/calebcadainoo"/>
    <language>en</language>
    <item>
      <title>Fixed ⚡️ - Android Manifest XML File Not Showing in VSCode</title>
      <dc:creator>Caleb Crosby Adainoo</dc:creator>
      <pubDate>Wed, 17 May 2023 14:31:30 +0000</pubDate>
      <link>https://dev.to/calebcadainoo/fixed-android-manifest-xml-file-not-showing-in-vscode-4j60</link>
      <guid>https://dev.to/calebcadainoo/fixed-android-manifest-xml-file-not-showing-in-vscode-4j60</guid>
      <description>&lt;p&gt;In this video, we address the issue of the Android Manifest file not appearing in VSCode. We provide solutions and troubleshooting techniques to help Android developers locate and access the crucial Manifest file. Whether you're a beginner or experienced, this tutorial offers valuable insights and practical tips for modifying XML files, understanding Manifest structures, and optimizing your Android development workflow in VSCode. Join us to overcome this obstacle and enhance your Android projects. Subscribe for more tutorials and productivity tips to take control of your Android development in VSCode.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You can watch the tutorial here&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://bit.ly/CrosbyRoadsYT"&gt;https://bit.ly/CrosbyRoadsYT&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;1_ &lt;strong&gt;Right-click the XML file&lt;/strong&gt; you want to modify or preview and select Open With... as shown in the picture below&lt;/p&gt;

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

&lt;p&gt;2_ Double-click &lt;strong&gt;Text Editor&lt;/strong&gt; as shown below&lt;/p&gt;

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

&lt;p&gt;3_ If you want to always view your XML files like any other file, eg. .html, .css, etc, any time you click it, &lt;strong&gt;repeat step 1&lt;/strong&gt;, select &lt;strong&gt;Text Editor&lt;/strong&gt; and then &lt;strong&gt;Configure default editor for ".xml"&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;4_ It will open up like this sample&lt;/p&gt;

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

&lt;p&gt;Thanks for stopping by to read this - kindly Subscribe to my YouTube channel for more tutorials and productivity tips.&lt;/p&gt;

&lt;p&gt;LIKE AND SUBSCRIBE ⚡️&lt;br&gt;
&lt;a href="https://bit.ly/CrosbyRoadsYT"&gt;https://bit.ly/CrosbyRoadsYT&lt;/a&gt;&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>android</category>
      <category>androidmanifest</category>
      <category>mobile</category>
    </item>
    <item>
      <title>Build an Image Previewer for your React TypeScript Form: A Step-by-Step Guide</title>
      <dc:creator>Caleb Crosby Adainoo</dc:creator>
      <pubDate>Sat, 29 Apr 2023 13:16:09 +0000</pubDate>
      <link>https://dev.to/calebcadainoo/building-an-image-previewer-for-your-react-typescript-form-a-step-by-step-guide-40mh</link>
      <guid>https://dev.to/calebcadainoo/building-an-image-previewer-for-your-react-typescript-form-a-step-by-step-guide-40mh</guid>
      <description>&lt;p&gt;In today's digital world, forms play a significant role in our everyday lives, whether it's for user registration or simply collecting data. However, it's not always easy to visualize what information is being submitted, especially when it comes to images. In this tutorial, we'll walk you through the process of building an image previewer for your React TypeScript form. With our step-by-step guide, you'll be able to provide your users with a seamless experience when submitting images. So, let's get started!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites:&lt;/strong&gt;&lt;br&gt;
Before getting started, make sure you have the following prerequisites:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;    Node.js installed on your machine.&lt;/li&gt;
&lt;li&gt;    A code editor like VSCode.&lt;/li&gt;
&lt;li&gt;    Basic knowledge of React and TypeScript.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Step 1: Setting up the React Application
&lt;/h2&gt;

&lt;p&gt;The first step is to set up a new React application &lt;/p&gt;

&lt;p&gt;&lt;em&gt;but if you have an existing app, you can ignore this step&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;To do this, we can use the Create React App (CRA) tool. Open a terminal and run the following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npx create-react-app my-app --template typescript&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
This command creates a new React application with TypeScript support.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 2: Creating the Form Component
&lt;/h2&gt;

&lt;p&gt;Next, we will create a form component that includes an input field for the file upload. In the &lt;code&gt;src&lt;/code&gt; folder, create a new file called &lt;code&gt;Form.tsx&lt;/code&gt; and add the following code:&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, { useState } from "react";

const Form = () =&amp;gt; {
  const [file, setFile] = useState&amp;lt;File | null&amp;gt;(null);

  const handleFileChange = (event: React.ChangeEvent&amp;lt;HTMLInputElement&amp;gt;) =&amp;gt; {
    const fileList = event.target.files;
    if (fileList &amp;amp;&amp;amp; fileList.length &amp;gt; 0) {
      setFile(fileList[0]);
    } else {
      setFile(null);
    }
  };

  const handleSubmit = (event: React.FormEvent&amp;lt;HTMLFormElement&amp;gt;) =&amp;gt; {
    event.preventDefault();
    console.log(file);
  };

  return (
    &amp;lt;form onSubmit={handleSubmit}&amp;gt;
      &amp;lt;label htmlFor="file-upload"&amp;gt;Choose a file:&amp;lt;/label&amp;gt;
      &amp;lt;input
        id="file-upload"
        type="file"
        accept="image/*"
        onChange={handleFileChange}
      /&amp;gt;
      &amp;lt;button type="submit"&amp;gt;Submit&amp;lt;/button&amp;gt;
    &amp;lt;/form&amp;gt;
  );
};

export default Form;

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

&lt;/div&gt;



&lt;p&gt;In this component, we use the &lt;code&gt;useState&lt;/code&gt; hook to manage the file state. We also use the &lt;code&gt;onChange&lt;/code&gt; event to handle changes to the file input. Finally, we use the &lt;code&gt;onSubmit&lt;/code&gt; event to handle form submission.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Adding the Image Preview Component
&lt;/h2&gt;

&lt;p&gt;Now, we will add an image preview component that displays a preview of the selected image. In the &lt;code&gt;src&lt;/code&gt; folder, create a new file called &lt;code&gt;ImagePreview.tsx&lt;/code&gt; and add the following code:&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";

type ImagePreviewProps = {
  file: File | null;
};

const ImagePreview = ({ file }: ImagePreviewProps) =&amp;gt; {
  if (!file) {
    return null;
  }

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;img
        src={URL.createObjectURL(file)}
        alt="Preview"
        // you can modify this styles to match your needs
        style={{ width: "300px", objectFit: "contain" }}
      /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};

export default ImagePreview;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this component, we use the &lt;code&gt;URL.createObjectURL&lt;/code&gt; method to create a URL for the selected file. We then use this URL as the &lt;code&gt;src&lt;/code&gt; attribute of the &lt;code&gt;img&lt;/code&gt; tag.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Updating the Form Component
&lt;/h2&gt;

&lt;p&gt;Now that we have created the &lt;code&gt;ImagePreview&lt;/code&gt; component, we need to update our Form component to display it. First, import the &lt;code&gt;ImagePreview&lt;/code&gt; component at the top of the &lt;code&gt;Form.tsx&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;Next, we can simply add the &lt;code&gt;ImagePreview&lt;/code&gt; component below the file input element in the &lt;code&gt;return&lt;/code&gt; statement of the &lt;code&gt;Form&lt;/code&gt; component:&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, { useState } from "react";
import ImagePreview from "./ImagePreview";

const Form = () =&amp;gt; {
  const [file, setFile] = useState&amp;lt;File | null&amp;gt;(null);

  const handleFileChange = (event: React.ChangeEvent&amp;lt;HTMLInputElement&amp;gt;) =&amp;gt; {
    const fileList = event.target.files;
    if (fileList &amp;amp;&amp;amp; fileList.length &amp;gt; 0) {
      setFile(fileList[0]);
    } else {
      setFile(null);
    }
  };

  const handleSubmit = (event: React.FormEvent&amp;lt;HTMLFormElement&amp;gt;) =&amp;gt; {
    event.preventDefault();
    console.log(file);
  };

  return (
    &amp;lt;form onSubmit={handleSubmit}&amp;gt;
      &amp;lt;label htmlFor="file-upload"&amp;gt;Choose a file:&amp;lt;/label&amp;gt;
      &amp;lt;input
        id="file-upload"
        type="file"
        accept="image/*"
        onChange={handleFileChange}
      /&amp;gt;
      &amp;lt;ImagePreview file={file} /&amp;gt;
      &amp;lt;button type="submit"&amp;gt;Submit&amp;lt;/button&amp;gt;
    &amp;lt;/form&amp;gt;
  );
};

export default Form
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this updated &lt;code&gt;Form&lt;/code&gt; component, we simply pass the file state as a prop to the &lt;code&gt;ImagePreview&lt;/code&gt; component. If there is a file selected, the &lt;code&gt;ImagePreview&lt;/code&gt; component will display a preview of it. If there is no file selected, the &lt;code&gt;ImagePreview&lt;/code&gt; component will not be displayed.&lt;/p&gt;

&lt;p&gt;That's it! We have successfully created an image previewer for our React TypeScript form. Now, our users can preview the image before submitting it, making the process much more user-friendly.&lt;/p&gt;

&lt;p&gt;Kindly consider subscribing to my YouTube channel here:&lt;br&gt;
&lt;a href="https://bit.ly/CrosbyRoads"&gt;https://bit.ly/CrosbyRoads&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Test URL: &lt;a href="https://bit.ly/3Li9OlB"&gt;https://bit.ly/3Li9OlB&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>typescript</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
