Skip to content

Commit b004aad

Browse files
author
Workflow
committed
deploy: 952601e
1 parent 0e4f0cf commit b004aad

13 files changed

+802
-670
lines changed

learn-react-native/creating-a-new-app.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,10 +731,13 @@ <h3 id="setup-2">Setup 2</h3>
731731
<pre><code class="language-js">module.exports = {
732732
preset: 'react-native',
733733
setupFilesAfterEnv: ['&lt;rootDir&gt;/jest-setup.ts'],
734+
moduleNameMapper: {
735+
&quot;^@shared/(.*)$&quot;: &quot;&lt;rootDir&gt;/src/shared/$1&quot;,
736+
},
734737
};
735738

736739
</code></pre>
737-
<div line-highlight="3,only"></div>
740+
<div line-highlight="3-6,only"></div>
738741
<p>✏️ Delete the unneeded generated folder <code>__tests__</code>.</p>
739742
<p>✏️ Create <strong>App.test.tsx</strong> and update it to be:</p>
740743
<pre><code class="language-tsx">import {render, screen} from '@testing-library/react-native';
@@ -969,6 +972,9 @@ <h3 id="setup-3">Setup 3</h3>
969972
<pre><code class="language-json">{
970973
&quot;extends&quot;: &quot;@react-native/typescript-config/tsconfig.json&quot;,
971974
&quot;compilerOptions&quot;: {
975+
&quot;paths&quot;: {
976+
&quot;@shared/*&quot;: [&quot;./src/shared/*&quot;]
977+
},
972978
&quot;module&quot;: &quot;ES2022&quot;,
973979
&quot;types&quot;: [&quot;react-native&quot;, &quot;jest&quot;, &quot;node&quot;],
974980

@@ -995,7 +1001,7 @@ <h3 id="setup-3">Setup 3</h3>
9951001
}
9961002

9971003
</code></pre>
998-
<div line-highlight="2-5,7-11,13-26,only"></div>
1004+
<div line-highlight="2-8,10-14,16-29,only"></div>
9991005
<p>✏️ Now that we have prettier and eslint set up, we need to make sure our code is following the new standards. You can apply most of the rules automatically. Run:</p>
10001006
<pre><code class="language-shell">npm run lint:fix
10011007
</code></pre>

learn-react-native/google-maps.html

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,12 +1248,11 @@ <h3 id="setup-1">Setup 1</h3>
12481248
<p>✏️ Terminate the existing dev server and start it again:</p>
12491249
<pre><code class="language-bash">npm run start
12501250
</code></pre>
1251-
<p>✏️ Create <strong>src/components/Tabs/Tabs.tsx</strong> and update it to be:</p>
1252-
<pre><code class="language-tsx">import { Pressable, StyleSheet } from &quot;react-native&quot;
1253-
1254-
import Box from &quot;../../design/Box&quot;
1255-
import { Theme, useTheme } from &quot;../../design/theme&quot;
1256-
import Typography from &quot;../../design/Typography&quot;
1251+
<p>✏️ Create <strong>src/shared/components/Tabs/Tabs.tsx</strong> and update it to be:</p>
1252+
<pre><code class="language-tsx">import Box from &quot;@shared/design/Box&quot;
1253+
import { Theme, useTheme } from &quot;@shared/design/theme&quot;
1254+
import Typography from &quot;@shared/design/Typography&quot;
1255+
import { Pressable, StyleSheet } from &quot;react-native&quot;
12571256

12581257
export interface TabsProps {
12591258
options: Array&lt;{
@@ -1325,19 +1324,18 @@ <h3 id="setup-1">Setup 1</h3>
13251324

13261325
</code></pre>
13271326
<div line-highlight='16, only'></div>
1328-
<p>✏️ Create <strong>src/components/Tabs/index.ts</strong> and update it to be:</p>
1327+
<p>✏️ Create <strong>src/shared/components/Tabs/index.ts</strong> and update it to be:</p>
13291328
<pre><code class="language-ts">export { default } from &quot;./Tabs&quot;
13301329
export * from &quot;./Tabs&quot;
13311330

13321331
</code></pre>
13331332
<p>✏️ Create <strong>src/screens/RestaurantList/components/List/List.tsx</strong> and update it to be:</p>
13341333
<pre><code class="language-tsx">import { useNavigation } from &quot;@react-navigation/native&quot;
1334+
import Button from &quot;@shared/design/Button&quot;
1335+
import Screen from &quot;@shared/design/Screen&quot;
1336+
import { Restaurant } from &quot;@shared/services/pmo/restaurant&quot;
13351337
import { FlatList } from &quot;react-native&quot;
13361338

1337-
import Button from &quot;../../../../design/Button&quot;
1338-
import Screen from &quot;../../../../design/Screen&quot;
1339-
import { Restaurant } from &quot;../../../../services/pmo/restaurant&quot;
1340-
13411339
export interface ListProps {
13421340
restaurants: Restaurant[]
13431341
}
@@ -1376,9 +1374,8 @@ <h3 id="setup-1">Setup 1</h3>
13761374

13771375
</code></pre>
13781376
<p>✏️ Create <strong>src/screens/RestaurantList/components/Map/Map.tsx</strong> and update it to be:</p>
1379-
<pre><code class="language-tsx">import MapView, { PROVIDER_GOOGLE } from &quot;react-native-maps&quot;
1380-
1381-
import { Restaurant } from &quot;../../../../services/pmo/restaurant&quot;
1377+
<pre><code class="language-tsx">import { Restaurant } from &quot;@shared/services/pmo/restaurant&quot;
1378+
import MapView, { PROVIDER_GOOGLE } from &quot;react-native-maps&quot;
13821379

13831380
export interface MapProps {
13841381
restaurants: Restaurant[]
@@ -1399,15 +1396,15 @@ <h3 id="setup-1">Setup 1</h3>
13991396
</code></pre>
14001397
<p>✏️ Update <strong>src/screens/RestaurantList/RestaurantList.tsx</strong> to be:</p>
14011398
<pre><code class="language-tsx">import { StackScreenProps } from &quot;@react-navigation/stack&quot;
1399+
import Loading from &quot;@shared/components/Loading&quot;
1400+
import Tabs from &quot;@shared/components/Tabs&quot;
1401+
import Box from &quot;@shared/design/Box&quot;
1402+
import Screen from &quot;@shared/design/Screen&quot;
1403+
import Typography from &quot;@shared/design/Typography&quot;
1404+
import { useRestaurants } from &quot;@shared/services/pmo/restaurant&quot;
14021405
import { useState } from &quot;react&quot;
14031406

14041407
import { RestaurantsStackParamList } from &quot;../../App&quot;
1405-
import Loading from &quot;../../components/Loading&quot;
1406-
import Tabs from &quot;../../components/Tabs&quot;
1407-
import Box from &quot;../../design/Box&quot;
1408-
import Screen from &quot;../../design/Screen&quot;
1409-
import Typography from &quot;../../design/Typography&quot;
1410-
import { useRestaurants } from &quot;../../services/pmo/restaurant&quot;
14111408

14121409
import List from &quot;./components/List&quot;
14131410
import Map from &quot;./components/Map&quot;
@@ -1462,7 +1459,7 @@ <h3 id="setup-1">Setup 1</h3>
14621459
export default RestaurantList
14631460

14641461
</code></pre>
1465-
<div line-highlight="2,6,12-13,26,44-51,54-58,only"></div>
1462+
<div line-highlight="3,8,12-13,26,44-51,54-58,only"></div>
14661463
<h3 id="verify-1">Verify 1</h3>
14671464
<p>Navigate to the <code>Maps</code> tab of the <code>RestaurantsList</code> in your emulator and verify that the Map is rendering.</p>
14681465
<p><img alt="Screenshot of how the application should look for the second solution." src="../static/img/react-native/18-maps/01-solution.png" style="border: 4px solid black; border-radius: 25px;" height="640"/></p>
@@ -1478,9 +1475,8 @@ <h3 id="solution-1">Solution 1</h3>
14781475
<p><details>
14791476
<summary>Click to see the solution</summary></p>
14801477
<p>✏️ Update <strong>src/screens/RestaurantList/components/Map/Map.tsx</strong> to be:</p>
1481-
<pre><code class="language-tsx">import MapView, { PROVIDER_GOOGLE } from &quot;react-native-maps&quot;
1482-
1483-
import { Restaurant } from &quot;../../../../services/pmo/restaurant&quot;
1478+
<pre><code class="language-tsx">import { Restaurant } from &quot;@shared/services/pmo/restaurant&quot;
1479+
import MapView, { PROVIDER_GOOGLE } from &quot;react-native-maps&quot;
14841480

14851481
export interface MapProps {
14861482
restaurants: Restaurant[]
@@ -1504,7 +1500,7 @@ <h3 id="solution-1">Solution 1</h3>
15041500
export default Map
15051501

15061502
</code></pre>
1507-
<div line-highlight="10-21,"></div>
1503+
<div line-highlight="9-20,"></div>
15081504
<p></details></p>
15091505
<h2 id="objective-2-add-restaurant-markers-with-tooltips-to-the-map">Objective 2: Add restaurant markers with tooltips to the map</h2>
15101506
<p>Now that we have a map, let’s add markers for each one of the restaurants.
@@ -1547,10 +1543,9 @@ <h3 id="adding-markers-to-a-map">Adding markers to a map</h3>
15471543
<h3 id="setup-2">Setup 2</h3>
15481544
<p>✏️ Update <strong>src/screens/RestaurantList/components/Map/Map.tsx</strong> to be:</p>
15491545
<pre><code class="language-tsx">import { useNavigation } from &quot;@react-navigation/native&quot;
1546+
import { Restaurant } from &quot;@shared/services/pmo/restaurant&quot;
15501547
import MapView, { Marker, PROVIDER_GOOGLE } from &quot;react-native-maps&quot;
15511548

1552-
import { Restaurant } from &quot;../../../../services/pmo/restaurant&quot;
1553-
15541549
export interface MapProps {
15551550
restaurants: Restaurant[]
15561551
}
@@ -1575,7 +1570,7 @@ <h3 id="setup-2">Setup 2</h3>
15751570
export default Map
15761571

15771572
</code></pre>
1578-
<div line-highlight="1-2,21-23,only"></div>
1573+
<div line-highlight="1,3,20-22,only"></div>
15791574
<h3 id="verify-2">Verify 2</h3>
15801575
<p>Navigate to the <code>Maps</code> tab of the <code>RestaurantsList</code> in your emulator and verify that the Map is rendering.</p>
15811576
<p><img alt="Screenshot of the restaurant view with the title “Green Bay, Wisconsin.” The map is still centered on Green Bay and now has several locations marked with red pins. One of the markers is labeled Cheese Curd City, 230 W Kinzie Street. The bottom tab bar has icons for Place My Order and Settings." src="../static/img/react-native/18-maps/02-solution.png" style="border: 4px solid black; border-radius: 25px;" height="640"/></p>
@@ -1593,10 +1588,9 @@ <h3 id="solution-2">Solution 2</h3>
15931588
<summary>Click to see the solution</summary></p>
15941589
<p>✏️ Update <strong>src/screens/RestaurantList/components/Map/Map.tsx</strong> to be:</p>
15951590
<pre><code class="language-tsx">import { useNavigation } from &quot;@react-navigation/native&quot;
1591+
import { Restaurant } from &quot;@shared/services/pmo/restaurant&quot;
15961592
import MapView, { Marker, PROVIDER_GOOGLE } from &quot;react-native-maps&quot;
15971593

1598-
import { Restaurant } from &quot;../../../../services/pmo/restaurant&quot;
1599-
16001594
export interface MapProps {
16011595
restaurants: Restaurant[]
16021596
}
@@ -1635,7 +1629,7 @@ <h3 id="solution-2">Solution 2</h3>
16351629
export default Map
16361630

16371631
</code></pre>
1638-
<div line-highlight="11,24-36,"></div>
1632+
<div line-highlight="10,23-35,"></div>
16391633
<p></details></p>
16401634
<h2 id="next-steps">Next steps</h2>
16411635
<p>We’ve accomplished a lot for our React Native App, in order to polish it just a bit more let’s get into some <a href="./performance-optimization">Performance and Optimization</a> practices.</p>

0 commit comments

Comments
 (0)