<?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: William Jackson</title>
    <description>The latest articles on Forem by William Jackson (@william98).</description>
    <link>https://forem.com/william98</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%2F314638%2F43ea68d8-e006-4e8a-b519-c99342001dea.jpg</url>
      <title>Forem: William Jackson</title>
      <link>https://forem.com/william98</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/william98"/>
    <language>en</language>
    <item>
      <title>How to Set up Rails MongoDB App in 10 minutes </title>
      <dc:creator>William Jackson</dc:creator>
      <pubDate>Thu, 12 Aug 2021 10:45:30 +0000</pubDate>
      <link>https://forem.com/william98/how-to-set-up-rails-mongodb-app-in-10-minutes-4fc</link>
      <guid>https://forem.com/william98/how-to-set-up-rails-mongodb-app-in-10-minutes-4fc</guid>
      <description>&lt;h2&gt;
  
  
  “MongoDB is a document database with the scalability and flexibility that you want with the querying and indexing that you need.”
&lt;/h2&gt;

&lt;p&gt;In this article, I am going to show you how to setup schema-less database MongoDB with your Rails 5 application. I am using Ubuntu 14.04, Ruby 2.5.1 and Rails 5.2 for this tutorial.&lt;/p&gt;

&lt;p&gt;If you have not installed Ruby on Rails MongoDB on your machine, then you first need to install it. Here are the steps.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo apt-key adv - keyserver hkp://keyserver.ubuntu.com:80 - recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.6 multiverse" | sudo tee
/etc/apt/sources.list.d/mongodb-org-3.6.list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo apt-get update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo apt-get install -y mongodb-org
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I have Ubuntu 14 but if you are using older or newer version then these steps may vary. You can find more details to install Rails MongoDB for these versions &lt;a href="https://askubuntu.com/questions/767934/mongodb-installation-failed-on-ubuntu-16-04/767965#767965"&gt;Here.&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Read More:&lt;/em&gt;&lt;/strong&gt; &lt;strong&gt;&lt;em&gt;&lt;a href="https://www.botreetechnologies.com/blog/how-to-install-and-use-mongodb-with-rails6"&gt;How to install and use MongoDB with Rails 6&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Once you finish the setup, start the MongoDB server. Here are some additional commands for that. To set up MongoDB:&lt;/p&gt;

&lt;p&gt;To start MongoDB use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo service mongod start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To stop MongoDB use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo service mongod stop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To restart MongoDB use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo service mongod restart
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s move to the Rails part now!&lt;/p&gt;

&lt;p&gt;Create a new rails application to use Ruby MongoDB. Make sure that you add –skip-active-record.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ rails new my_mongo_app --skip-active-record
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you notice, there is no database.yml and no sqlite3 gem is added automatically. Now we have to add two gems which will be a bridge for us between Rails and MongoDB.&lt;/p&gt;

&lt;p&gt;Add the following gems to Gemfile.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gem 'mongoid', '~&amp;gt; 6.0'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gem 'bson_ext'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now do bundle install. Now we have to generate &lt;code&gt;mongoid.yml&lt;/code&gt; file which is similar to database.yml file for us.&lt;/p&gt;

&lt;p&gt;Run the following command to generate MongoDB configuration files.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rails g mongoid:config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now update mongoid.yml file based on your MongoDB configurations and create a database with rake db:create Mongoid provides these generators to manage database with these rake tasks.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Read Also :&lt;/em&gt;&lt;/strong&gt; &lt;strong&gt;&lt;em&gt;&lt;a href="https://www.botreetechnologies.com/blog/extracting-text-from-image-using-google-cloud-vision-ocr-with-ruby"&gt;Extracting text from image using Google Cloud vision OCR with Ruby&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To add a model you can use scaffold and Mongoid will automatically add a module include Mongoid::Document in that class. Here’s the Rails scaffold example and code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rails g scaffold article name:string content:text
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will generate all files as we usually have in normal scaffolding and you can access it from /articles.&lt;/p&gt;

&lt;p&gt;That’s it. Your Rails application is ready for use with MongoDB. For more details regarding Ruby mongo gem visit, &lt;a href="https://docs.mongodb.com/"&gt;this page&lt;/a&gt; If you want to get more Rails specific details, then visit &lt;a href="https://docs.mongodb.com/mongoid/master/tutorials/mongoid-rails/"&gt;this page.&lt;/a&gt;&lt;/p&gt;

</description>
      <category>mongodb</category>
      <category>rails</category>
      <category>tutorial</category>
      <category>programming</category>
    </item>
    <item>
      <title>Top 50 React Native interview questions (with answers) ✔✔
</title>
      <dc:creator>William Jackson</dc:creator>
      <pubDate>Tue, 10 Aug 2021 18:33:05 +0000</pubDate>
      <link>https://forem.com/william98/top-10-react-native-interview-questions-with-answers-40d5</link>
      <guid>https://forem.com/william98/top-10-react-native-interview-questions-with-answers-40d5</guid>
      <description>&lt;p&gt;React is one of the most popular JavaScript front-end frameworks on the market today, and its popularity continues to grow. It’s estimated that over 8,000 companies use this JavaScript framework, including big names like Facebook, Instagram, Airbnb, and more. Many companies are looking for talented React developers.&lt;/p&gt;

&lt;p&gt;Cracking your React Native interview is essential to landing one of these roles. To help you prepare, we’ve gathered the top 50 React Native interview questions. This guide includes questions and answers. Let’s get started!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We’ll cover:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;25 React Native interview questions with answers&lt;/li&gt;
&lt;li&gt;
25 more interview questions to explore
&lt;/li&gt;
&lt;li&gt;
Next steps
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;a&gt;&lt;/a&gt;React Native interview questions with answers
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. How is React Native different from ReactJS?
&lt;/h3&gt;

&lt;p&gt;React Native is a JavaScript framework that was developed by Facebook to meet the growing needs of mobile app development. It’s open-source and based on JavaScript. It was designed to build native mobile apps with reusable components. It uses a lot of ReactJS components but implements them in a native way across different devices. It invokes the native rendering APIs in Objective-C (for IOS) and Java (for Android).&lt;/p&gt;

&lt;p&gt;ReactJS was also developed by Facebook. It’s an open-source JavaScript library used for developing responsive user interfaces for mobile and web applications. It has a library of reusable components that are meant to help developers build the foundation for their apps.&lt;/p&gt;

&lt;p&gt;Let’s take a look at some of their key differences:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt; React Native and ReactJS both use JSX, but ReactJS uses HTML tags, and React Native doesn’t.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Navigation:&lt;/strong&gt; React Native uses its own built-in navigation library, while ReactJS uses a react-router.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Animation:&lt;/strong&gt; ReactJS uses CSS animations. React Native uses its animated API.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;DOM:&lt;/strong&gt; ReactJS uses a virtual DOM with a partial refresh. React Native needs to use its native API when rendering UI components.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Usage:&lt;/strong&gt; ReactJS is mainly used for web app development, while React Native focuses on mobile applications.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. What is JSX?
&lt;/h3&gt;

&lt;p&gt;JavaScript XML, or JSX, is a XML/HTML template syntax used by React. It extends ECMAScript, which allows XML/HTML-like text to coincide with JavaScript and React code. It allows us to put HTML into JavaScript.&lt;/p&gt;

&lt;p&gt;It’s faster than normal JavaScript, makes it easier to create templates, and uses components. It comes with the full power of JavaScript, and you can use it with React to describe what the user interface should look like. Let’s take a look at a &lt;code&gt;Hello World!&lt;/code&gt; in JSX:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;element&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Hello&lt;/span&gt; &lt;span class="nx"&gt;World&lt;/span&gt;&lt;span class="o"&gt;!&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. What are the core React Components and what do they do?
&lt;/h3&gt;

&lt;p&gt;The core React components include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Props:&lt;/strong&gt; You can use props to pass data to different React components. Props are immutable, which means props can’t change their values.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;ScrollView:&lt;/strong&gt; ScrollView is a scrolling container that’s used to host multiple views. You can use it to render large lists or content.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;States:&lt;/strong&gt; You use states to control components. The state is mutable in React, meaning that it can change the value at any time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Style:&lt;/strong&gt; React Native doesn’t require any special syntax for styling. It uses the JavaScript object.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Text:&lt;/strong&gt; The text components display text in your application. It uses textInput to take input from the user.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;View:&lt;/strong&gt; View is used to build the UI for mobile applications. It’s a place where you can display your content.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. How do you install and create a React Native application?
&lt;/h3&gt;

&lt;p&gt;Before you begin, make sure you have Node.js and NPM installed on your system.&lt;/p&gt;

&lt;p&gt;To install a React Native application, you can use the following command:&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 -g create-react-native-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To create a React Native project, you can use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ create-react-native-app AppName
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To navigate in your project, use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cd AppName
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And to start your project, run this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. What is Redux and when should you use it?
&lt;/h3&gt;

&lt;p&gt;Redux is a state management tool for JavaScript applications. It helps you write apps that are consistent, apps that can be run in different environments, and apps that are easy to test.&lt;/p&gt;

&lt;p&gt;Not all applications need Redux. It’s designed to help you determine when you experience state changes. According to the official Redux documentation, here are some examples of when you’d want to use Redux:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your app state is updated frequently&lt;/li&gt;
&lt;li&gt;You have a large amount of app state and it’s needed in many places within the app&lt;/li&gt;
&lt;li&gt;The logic to update your app state is complicated&lt;/li&gt;
&lt;li&gt;You want to see how the state is being updated over time&lt;/li&gt;
&lt;li&gt;Your app has a medium or large-sized codebase and will be worked on by multiple people&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  6. What is &lt;code&gt;state&lt;/code&gt; and how do you use it?
&lt;/h3&gt;

&lt;p&gt;In React Native, &lt;code&gt;state&lt;/code&gt; handles data that is changeable. &lt;code&gt;state&lt;/code&gt; is mutable, meaning that it can change the value at any time. You should initialize it in the constructor, and then call &lt;code&gt;setState&lt;/code&gt; when you want to change it. Let’s look at a code example of how to create a text class component using state data:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;StyleSheet&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react-native&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;TextExample&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
      &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="na"&gt;titleText&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;What is React Native?&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;bodyText&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;React Native is a JavaScript framework.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
      &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7. How do you debug React apps and what tools can you use?
&lt;/h3&gt;

&lt;p&gt;There are many different ways to do your debugging in React Native applications. Since React Native has both IOS and Android environments, there’s a wide range of different problems you can encounter and a wide range of different tools needed. We’re going to explore a few different ways to debug. Let’s start with outlining the dev menu:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Developer menu&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The developer menu includes some different ways to debug and access debugging tools.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Reload:&lt;/strong&gt; reloads the app&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Debug JS Remotely:&lt;/strong&gt; opens to a JavaScript debugger&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Enable Live Reload:&lt;/strong&gt; causes the app to reload automatically after selecting “Save”&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Enable Hot Reloading:&lt;/strong&gt; watches for changes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Toggle Inspector:&lt;/strong&gt; toggles the inspector interface so we can inspect UI elements and their properties&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Show Perf Monitor:&lt;/strong&gt; monitors performance&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Chrome DevTools&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can use these DevTools to debug React Native apps. You need to make sure that it’s connected to the same WiFi. If you’re using Windows or Linux, press &lt;em&gt;Ctrl + M+&lt;/em&gt;, and if you’re using macOS, press &lt;em&gt;Command + R&lt;/em&gt;. In the developer menu, you select “Debug JS Remotely” and it will open the default debugger.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;React Developer Tools&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To use React’s Developer Tools, you have to use the desktop app. These tools allow you to debug React components and styles.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;React Native Debugger&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you’re using Redux in your React app, this is a good debugger for you. It’s a desktop app that integrates Redux’s and React’s developer tools in one app.&lt;/p&gt;

&lt;p&gt;React Native CLI&lt;/p&gt;

&lt;p&gt;You can use the React Native command-line interface to do debugging as well.&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Build a React app that does nothing except say “Hello World!”
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;View&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react-native&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;HelloWorldApp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;View&lt;/span&gt;
            &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="na"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;justifyContent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;center&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;alignItems&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;center&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Hello World!&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;View&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;HelloWorldApp&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  9. Can you write code for Android and IOS in the same codebase?
&lt;/h3&gt;

&lt;p&gt;Yes, you can! React takes care of all of the native component translations.&lt;/p&gt;

&lt;h3&gt;
  
  
  10. Describe how to re-render a FlatList.
&lt;/h3&gt;

&lt;p&gt;You can &lt;code&gt;re-render&lt;/code&gt; a FlatList by using the &lt;code&gt;extraData&lt;/code&gt; property. Let’s look at a JavaScript code example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;FlatList&lt;/span&gt;
    &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;FlatListstyles&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="na"&gt;extraData&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="na"&gt;renderItem&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_renderItem&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When we pass &lt;code&gt;extraData={this.state}&lt;/code&gt; to the FlatList, we ensure it’ll re-render itself when the selected state changes. Since &lt;code&gt;FlatList&lt;/code&gt; is also a &lt;code&gt;PureComponent&lt;/code&gt;, we need to set this prop so it knows to re-render items.&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;br&gt;
&lt;a&gt;&lt;/a&gt;&lt;br&gt;
Read More : 👉👉 &lt;strong&gt;&lt;a href="https://bit.ly/3Ar1tVM"&gt;Top 50 React Native interview questions (with answers)&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>javascript</category>
      <category>typescript</category>
      <category>redux</category>
    </item>
  </channel>
</rss>
