File size: 202,237 Bytes
0791e78 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 |
[
{
"text": "[MUSIC PLAYING]",
"start": 0.0,
"duration": 2.495
},
{
"text": "SPEAKER 1: Hello and welcome\nfor Lecture 3 in React Native.",
"start": 16.48,
"duration": 3.844
},
{
"text": "So previous lecture we talked\nabout a bunch of different topics;",
"start": 20.324,
"duration": 2.666
},
{
"text": "one being classes and how ES6\nallows you to write classes.",
"start": 22.99,
"duration": 4.23
},
{
"text": "React, we talked about\nthe library by Facebook",
"start": 27.22,
"duration": 2.73
},
{
"text": "that allows you to write\ndeclarative programming.",
"start": 29.95,
"duration": 2.309
},
{
"text": "We talked about what imperative\nand declarative programming were",
"start": 32.259,
"duration": 3.721
},
{
"text": "and how React allows you\nto write declaratively.",
"start": 35.98,
"duration": 2.4
},
{
"text": "We talked about props, which\nare basically an object that",
"start": 38.38,
"duration": 2.55
},
{
"text": "are passed down to elements.",
"start": 40.93,
"duration": 1.71
},
{
"text": "We talked about state, which is a\nmanagement system for allowing you",
"start": 42.64,
"duration": 6.09
},
{
"text": "to track state in a class component.",
"start": 48.73,
"duration": 3.06
},
{
"text": "We implemented the to do app in\nReact and then we teased at something",
"start": 51.79,
"duration": 3.57
},
{
"text": "called React Native.",
"start": 55.36,
"duration": 1.71
},
{
"text": "And so this lecture we'll be\ntalking a lot about React Native.",
"start": 57.07,
"duration": 2.73
},
{
"text": "React Native is a framework\nthat relies on React Core.",
"start": 59.8,
"duration": 3.0
},
{
"text": "And so a lot of the paradigms that apply\nto React also apply to React Native.",
"start": 62.8,
"duration": 4.79
},
{
"text": "And it allows us to build mobile\napps using only JavaScript.",
"start": 67.59,
"duration": 3.76
},
{
"text": "And so, as the React team like\nto say when this was released,",
"start": 71.35,
"duration": 4.14
},
{
"text": "you can learn once and write everywhere.",
"start": 75.49,
"duration": 4.11
},
{
"text": "And so React Native\nsupports iOS and Android,",
"start": 79.6,
"duration": 2.31
},
{
"text": "and we'll see later today\nhow we get that going.",
"start": 81.91,
"duration": 4.62
},
{
"text": "And so how exactly does this work?",
"start": 86.53,
"duration": 1.99
},
{
"text": "How are we allowed to write JavaScript\nand have it run on mobile devices?",
"start": 88.52,
"duration": 4.85
},
{
"text": "So first, the JavaScript is bundled.",
"start": 93.37,
"duration": 1.5
},
{
"text": "So, just like in React, what happens\nare a couple of different steps",
"start": 94.87,
"duration": 4.17
},
{
"text": "where your JavaScript is transpilaged\nso going from ES6, ES7, ES-next,",
"start": 99.04,
"duration": 5.61
},
{
"text": "down to ES5 code, and\nit's also minified.",
"start": 104.65,
"duration": 3.65
},
{
"text": "And so throughout the process you\ngo from a bunch of different files",
"start": 108.3,
"duration": 2.86
},
{
"text": "all to one big JavaScript bundle.",
"start": 111.16,
"duration": 3.81
},
{
"text": "This runs on your phone.",
"start": 114.97,
"duration": 1.327
},
{
"text": "There are separate threads\nfor UI layout and JavaScript.",
"start": 116.297,
"duration": 2.333
},
{
"text": "And so, as we saw, if we're\nrunning JavaScript in the browser",
"start": 118.63,
"duration": 2.73
},
{
"text": "and that locks up, then nothing works.",
"start": 121.36,
"duration": 2.899
},
{
"text": "But in React Native there\nare actually separate threads",
"start": 124.259,
"duration": 2.291
},
{
"text": "for the UI layout and JavaScript.",
"start": 126.55,
"duration": 1.95
},
{
"text": "And these different threads communicate\nasynchronously through a bridge.",
"start": 131.95,
"duration": 5.44
},
{
"text": "And so the JavaScript\nthread will request",
"start": 137.39,
"duration": 2.18
},
{
"text": "UI elements to be shown and\nthen, like I alluded to earlier,",
"start": 139.57,
"duration": 4.45
},
{
"text": "the JavaScript thread can be\nblocked and the UI still works.",
"start": 144.02,
"duration": 2.92
},
{
"text": "And so what do I mean by this bridge?",
"start": 146.94,
"duration": 3.86
},
{
"text": "And so what ends up happening\nis there are separate threads.",
"start": 150.8,
"duration": 3.14
},
{
"text": "So there's one thread for the UI and\nthere's one thread for JavaScript.",
"start": 153.94,
"duration": 5.275
},
{
"text": "And so say we're writing React and\nwe have something like a button",
"start": 162.54,
"duration": 7.43
},
{
"text": "that we want to be shown.",
"start": 169.97,
"duration": 1.97
},
{
"text": "Basically what happens is\nthere's this bridge which will",
"start": 171.94,
"duration": 7.56
},
{
"text": "communicate between these two threads.",
"start": 179.5,
"duration": 1.59
},
{
"text": "And so the JavaScript\nwill basically say,",
"start": 181.09,
"duration": 2.11
},
{
"text": "hey UI thread I want a view or a button.",
"start": 183.2,
"duration": 4.49
},
{
"text": "And then UI will basically\nsay, OK here it is a button.",
"start": 194.4,
"duration": 4.197
},
{
"text": "And then if I, as a\nuser, go ahead and press",
"start": 198.597,
"duration": 1.833
},
{
"text": "that the UI will actually\nsend over to the JavaScript,",
"start": 200.43,
"duration": 4.427
},
{
"text": "oh the button was pressed.",
"start": 204.857,
"duration": 1.083
},
{
"text": "And so this bridge here\nis asynchronous, so",
"start": 214.32,
"duration": 2.64
},
{
"text": "if something happens on the JavaScript\nand the JavaScript is actually",
"start": 216.96,
"duration": 2.94
},
{
"text": "clogged and blocking, the UI\nthread can still do its thing",
"start": 219.9,
"duration": 3.18
},
{
"text": "and I'll show you an\nexample of that in a second.",
"start": 223.08,
"duration": 2.62
},
{
"text": "And, conversely, when you\ntouch something on the UI",
"start": 225.7,
"duration": 4.25
},
{
"text": "the JavaScript doesn't know\nuntil the bridge basically says,",
"start": 229.95,
"duration": 3.73
},
{
"text": "hey, this button was pressed and the\nUI can talk to the JavaScript that way.",
"start": 233.68,
"duration": 4.46
},
{
"text": "And so let's see some example where\nwe can lock up that JavaScript thread",
"start": 238.14,
"duration": 4.83
},
{
"text": "and not have the UI lock up.",
"start": 242.97,
"duration": 3.24
},
{
"text": "And so here we are in\nthe Snack, snack.expo.io,",
"start": 246.21,
"duration": 5.49
},
{
"text": "and this allows us to run React Native\nand have it all happen in the browser.",
"start": 251.7,
"duration": 4.92
},
{
"text": "And so a few lectures ago we wrote this\nblocking method that basically locks up",
"start": 256.62,
"duration": 6.404
},
{
"text": "the JavaScript thread.",
"start": 263.024,
"duration": 0.916
},
{
"text": "So we can go ahead and do that again.",
"start": 263.94,
"duration": 1.61
},
{
"text": "So say we have a method\ncalled block JavaScript.",
"start": 265.55,
"duration": 4.33
},
{
"text": "And what that does is you can say, we're\ngoing to block and then do this thing,",
"start": 269.88,
"duration": 9.4
},
{
"text": "so while date.now so we can say,\ncons done is five seconds from now.",
"start": 279.28,
"duration": 9.68
},
{
"text": "And we can say, while it has not\nbeen that much time just do nothing.",
"start": 293.9,
"duration": 5.31
},
{
"text": "And then when that's done\nwe can say, OK we're done.",
"start": 302.904,
"duration": 2.166
},
{
"text": "And so down here, let's\nactually create a scroll view--",
"start": 310.78,
"duration": 3.07
},
{
"text": "we'll see what that is in a second--",
"start": 313.85,
"duration": 1.5
},
{
"text": "and a button.",
"start": 320.239,
"duration": 0.541
},
{
"text": "And we actually don't care\nabout any of all that stuff.",
"start": 328.999,
"duration": 2.291
},
{
"text": "And so, when this\nbutton is clicked, we're",
"start": 341.691,
"duration": 1.749
},
{
"text": "going to go ahead and\nblock that JavaScript.",
"start": 343.44,
"duration": 1.9
},
{
"text": "All right.",
"start": 356.61,
"duration": 0.98
},
{
"text": "So everybody following?",
"start": 361.52,
"duration": 1.0
},
{
"text": "So, so far we have a scroll view\nwhich is basically just a view that",
"start": 362.52,
"duration": 4.83
},
{
"text": "can scroll back and forth.",
"start": 367.35,
"duration": 2.08
},
{
"text": "We have a button that says block\nJavaScript, and when it's clicked,",
"start": 369.43,
"duration": 3.95
},
{
"text": "it will run this function\nthat blocks the JavaScript.",
"start": 373.38,
"duration": 3.375
},
{
"text": "And so watch what happens\nwhen I click this button.",
"start": 376.755,
"duration": 3.255
},
{
"text": "Small bug.",
"start": 391.24,
"duration": 0.99
},
{
"text": "All right here's a chance.",
"start": 398.437,
"duration": 1.083
},
{
"text": "Who can spot the bug?",
"start": 399.52,
"duration": 0.874
},
{
"text": "Oh, on press.",
"start": 407.0,
"duration": 2.71
},
{
"text": "So on press, it will actually\nblock the JavaScript.",
"start": 409.71,
"duration": 2.46
},
{
"text": "And you see how it still is scrolling,\nbut that button is locked up.",
"start": 412.17,
"duration": 4.26
},
{
"text": "And then only after five seconds\nhave passed do the logs come through",
"start": 416.43,
"duration": 4.68
},
{
"text": "and then the button returns\nto its normal state.",
"start": 421.11,
"duration": 3.15
},
{
"text": "But notice how when it\nwas stuck and locked,",
"start": 424.26,
"duration": 2.302
},
{
"text": "when the JavaScript thread\nwas locked, we still",
"start": 426.562,
"duration": 1.958
},
{
"text": "had the ability to\nscroll back and forth.",
"start": 428.52,
"duration": 2.85
},
{
"text": "That's because all of the JavaScript\nis controlled on one thread",
"start": 431.37,
"duration": 3.12
},
{
"text": "whereas on the other thread all of the\nUI elements still worked as intended.",
"start": 434.49,
"duration": 4.9
},
{
"text": "And so even though the JavaScript\nthread was locked up here,",
"start": 439.39,
"duration": 2.51
},
{
"text": "it was in this while loop\ndoing nothing, the UI elements",
"start": 441.9,
"duration": 4.05
},
{
"text": "were still able to\nscroll back and forth.",
"start": 445.95,
"duration": 2.86
},
{
"text": "And so it's not as big\nof a deal if you lock up",
"start": 448.81,
"duration": 3.59
},
{
"text": "the JavaScript thread in React\nNative but it's still a big deal",
"start": 452.4,
"duration": 3.45
},
{
"text": "because none of your\nevent handlers will fire.",
"start": 455.85,
"duration": 3.87
},
{
"text": "So any questions about how React Native\nworks, how these UI and JavaScript",
"start": 462.75,
"duration": 5.45
},
{
"text": "threads run separately in the bridge?",
"start": 468.2,
"duration": 3.0
},
{
"text": "Great.",
"start": 471.2,
"duration": 1.86
},
{
"text": "And so what are some of the differences\nbetween React Native and React Web",
"start": 473.06,
"duration": 3.15
},
{
"text": "which we've been talking about thus far?",
"start": 476.21,
"duration": 2.157
},
{
"text": "So there are differences\nin base components.",
"start": 478.367,
"duration": 1.833
},
{
"text": "So as you saw in my quick example,\nthings like scroll view or capital",
"start": 480.2,
"duration": 3.63
},
{
"text": "button do not exist in web.",
"start": 483.83,
"duration": 2.205
},
{
"text": "Things like style, the way\nthat you style elements,",
"start": 486.035,
"duration": 2.125
},
{
"text": "is slightly different in React\nNative and you don't actually",
"start": 488.16,
"duration": 3.23
},
{
"text": "have browser APIs anymore.",
"start": 491.39,
"duration": 2.79
},
{
"text": "So things like CSS, animations,\ncanvas, SVG, things like that",
"start": 494.18,
"duration": 4.17
},
{
"text": "don't actually exist in React Native.",
"start": 498.35,
"duration": 2.467
},
{
"text": "But there are actually things\nthat have been polyfilled.",
"start": 500.817,
"duration": 2.333
},
{
"text": "So polyfilled is a term that people use\nto mean some methods or functions that",
"start": 503.15,
"duration": 6.9
},
{
"text": "might exist in one environment do not\nnecessarily exist in all environments.",
"start": 510.05,
"duration": 3.97
},
{
"text": "And by polyfilling these we can\nactually implement them such",
"start": 514.02,
"duration": 3.92
},
{
"text": "that all environments\nwill actually have these.",
"start": 517.94,
"duration": 2.03
},
{
"text": "And so fetch is something that's\nnot supported by all browsers,",
"start": 519.97,
"duration": 4.199
},
{
"text": "but by polyfilling it\nyou can actually include",
"start": 524.169,
"duration": 2.891
},
{
"text": "code that will implement fetch\nif it doesn't exist already.",
"start": 527.06,
"duration": 2.88
},
{
"text": "And so things like fetch timers like\nset interval or console or console.log,",
"start": 529.94,
"duration": 6.24
},
{
"text": "console.warn, and stuff like\nthat have been polyfilled so",
"start": 536.18,
"duration": 3.995
},
{
"text": "that they work in React Native as well.",
"start": 540.175,
"duration": 4.144
},
{
"text": "And also the way that\nyou handle navigation",
"start": 544.319,
"duration": 1.791
},
{
"text": "is slightly different in\nReact Native, and we'll",
"start": 546.11,
"duration": 1.999
},
{
"text": "talk about that in a future lecture.",
"start": 548.109,
"duration": 1.993
},
{
"text": "And so I said that React Native base\ncomponents are slightly different.",
"start": 550.102,
"duration": 2.958
},
{
"text": "And so what do I mean there?",
"start": 553.06,
"duration": 2.81
},
{
"text": "So in React Web we had access to\nthings like div or span or P image,",
"start": 555.87,
"duration": 4.82
},
{
"text": "and we can just declare those globally.",
"start": 560.69,
"duration": 2.84
},
{
"text": "But in React Native we actually have to\nimport from the React Native library,",
"start": 563.53,
"duration": 4.6
},
{
"text": "and we'll see how to do\nthat in a little bit.",
"start": 568.13,
"duration": 2.64
},
{
"text": "And so divs no longer exist and\nwhat we use instead are Views.",
"start": 570.77,
"duration": 2.84
},
{
"text": "So View with a capital V is basically\na cross-platform, just blank E-Y slate.",
"start": 573.61,
"duration": 7.58
},
{
"text": "So basically the same thing as a div.",
"start": 581.19,
"duration": 3.17
},
{
"text": "There's no such thing\nas span or P anymore",
"start": 584.36,
"duration": 2.31
},
{
"text": "and so instead we use this text.",
"start": 586.67,
"duration": 1.887
},
{
"text": "And so what's unique in React\nNative is that all text actually",
"start": 588.557,
"duration": 2.583
},
{
"text": "must be wrapped by this text tag.",
"start": 591.14,
"duration": 3.69
},
{
"text": "As you saw in this previous\nexample lower case button",
"start": 594.83,
"duration": 2.52
},
{
"text": "doesn't exist anymore.",
"start": 597.35,
"duration": 1.45
},
{
"text": "Instead, we use capitol Button\nwith a slightly different API.",
"start": 598.8,
"duration": 2.81
},
{
"text": "And so from React Web, if you\nwant to attach a handler to that",
"start": 601.61,
"duration": 3.66
},
{
"text": "you do on click.",
"start": 605.27,
"duration": 1.2
},
{
"text": "Whereas, in React Native, you\ndo on press which was actually",
"start": 606.47,
"duration": 3.78
},
{
"text": "the bug in the code earlier.",
"start": 610.25,
"duration": 2.85
},
{
"text": "And lastly we have these things\ncalled scroll views or lists which",
"start": 613.1,
"duration": 3.87
},
{
"text": "don't really exist in web world, but\nthey do exist a lot in React Native,",
"start": 616.97,
"duration": 5.82
},
{
"text": "and we'll be talking about\nthose in the future as well.",
"start": 622.79,
"duration": 2.852
},
{
"text": "Of course there are many,\nmany other components",
"start": 625.642,
"duration": 1.958
},
{
"text": "and, if you want to explore them,\nthe documentation is really good.",
"start": 627.6,
"duration": 3.84
},
{
"text": "Cool, so let's actually\ntake that example",
"start": 634.52,
"duration": 2.04
},
{
"text": "that we wrote last lecture,\nthe to do app, and actually",
"start": 636.56,
"duration": 3.36
},
{
"text": "translate it into React Native.",
"start": 639.92,
"duration": 2.12
},
{
"text": "And so I have here this implementation,\nwhich is exactly the code",
"start": 642.04,
"duration": 6.82
},
{
"text": "that we wrote in the previous lecture.",
"start": 648.86,
"duration": 1.624
},
{
"text": "And what we're going to do is\ncopy and paste that into the Snack",
"start": 650.484,
"duration": 2.666
},
{
"text": "that we saw earlier and go ahead and\ntranslate that into React Native.",
"start": 653.15,
"duration": 3.18
},
{
"text": "So this is just the command\nto copy it and let's actually",
"start": 661.67,
"duration": 4.74
},
{
"text": "paste that into here.",
"start": 666.41,
"duration": 3.15
},
{
"text": "So of course there's going to be many\nerrors just because this is React Web",
"start": 669.56,
"duration": 3.27
},
{
"text": "and we're trying to run\nthis in React Native.",
"start": 672.83,
"duration": 2.22
},
{
"text": "And so let's go ahead and\ntry to fix those errors.",
"start": 675.05,
"duration": 3.27
},
{
"text": "And so first we see stuff like\nLI, input, button, and those",
"start": 678.32,
"duration": 4.71
},
{
"text": "don't exist in React Native.",
"start": 683.03,
"duration": 1.32
},
{
"text": "And so we'll have to first\nreplace those React Web",
"start": 684.35,
"duration": 3.45
},
{
"text": "components with React Native ones.",
"start": 687.8,
"duration": 3.85
},
{
"text": "And so this rendering\ndoes not exist anymore.",
"start": 691.65,
"duration": 2.255
},
{
"text": "And so let's first do import\nsome stuff from React Native.",
"start": 693.905,
"duration": 6.375
},
{
"text": "And we'll be talking about imports\nand exports a little bit later,",
"start": 700.28,
"duration": 3.82
},
{
"text": "but just bear with me for now.",
"start": 704.1,
"duration": 1.73
},
{
"text": "And so some things that we're\ngoing to need are stuff like View,",
"start": 705.83,
"duration": 3.16
},
{
"text": "we'll need a Button and we'll need text.",
"start": 708.99,
"duration": 2.72
},
{
"text": "And we'll need some scrolling\nviews and then maybe",
"start": 715.88,
"duration": 4.71
},
{
"text": "some more stuff in a little bit.",
"start": 720.59,
"duration": 2.07
},
{
"text": "So first let's work on\nthat quick to do component.",
"start": 722.66,
"duration": 3.36
},
{
"text": "And so we have a list item here,\ninstead let's actually use a View.",
"start": 726.02,
"duration": 3.15
},
{
"text": "Let's actually get rid of this input for\nnow, and we'll add that in a little bit",
"start": 734.2,
"duration": 4.35
},
{
"text": "later.",
"start": 738.55,
"duration": 1.05
},
{
"text": "But how are we going to change this\nlowercase button to React Native?",
"start": 739.6,
"duration": 4.336
},
{
"text": "Well first we need to replace it\nwith the capital Button, which",
"start": 743.936,
"duration": 2.624
},
{
"text": "is React Natives version of the button.",
"start": 746.56,
"duration": 2.174
},
{
"text": "It no longer has an on click\nproperty and so instead we'll",
"start": 748.734,
"duration": 2.416
},
{
"text": "pass an on press prop and then we don't\nactually wrap the content any more",
"start": 751.15,
"duration": 6.69
},
{
"text": "instead we pass a title prop.",
"start": 757.84,
"duration": 2.48
},
{
"text": "And so that button's done.",
"start": 763.026,
"duration": 1.874
},
{
"text": "What are we going to do for span?",
"start": 764.9,
"duration": 1.73
},
{
"text": "Anyone?",
"start": 766.63,
"duration": 1.536
},
{
"text": "AUDIENCE: [INAUDIBLE]",
"start": 768.166,
"duration": 0.874
},
{
"text": "SPEAKER 1: Yeah, we'll\nuse a text instead.",
"start": 769.04,
"duration": 1.749
},
{
"text": "And now our to do is done.",
"start": 773.41,
"duration": 2.73
},
{
"text": "So now let's start looking\ninto this app component.",
"start": 776.14,
"duration": 3.201
},
{
"text": "So first let's get rid of this render,\nwhich does not exist in React Native,",
"start": 782.17,
"duration": 5.94
},
{
"text": "and let's start working our way\nthrough this big return function here.",
"start": 788.11,
"duration": 3.48
},
{
"text": "So first we have a div.",
"start": 791.59,
"duration": 1.23
},
{
"text": "Instead of a div let's\ngo ahead and use a View.",
"start": 792.82,
"duration": 2.25
},
{
"text": "And then we have a to do count.",
"start": 798.639,
"duration": 1.291
},
{
"text": "So what are we going to\nuse instead of this div?",
"start": 799.93,
"duration": 3.27
},
{
"text": "We can't use a View\notherwise an error will",
"start": 803.2,
"duration": 1.86
},
{
"text": "be thrown because remember the\nonly way that we can include text",
"start": 805.06,
"duration": 3.63
},
{
"text": "in React Native is by wrapping it in\nthis text component and same thing",
"start": 808.69,
"duration": 5.921
},
{
"text": "with this.",
"start": 814.611,
"duration": 0.499
},
{
"text": "All right, we see another button\nand we've seen a button before,",
"start": 817.924,
"duration": 2.666
},
{
"text": "so all we have to do is replace\nthat lowercase b with a capital B,",
"start": 820.59,
"duration": 3.5
},
{
"text": "change on click to on press and\nchange the content to be title.",
"start": 824.09,
"duration": 4.495
},
{
"text": "And then we're done there.",
"start": 835.007,
"duration": 1.083
},
{
"text": "All right, UL, unordered lists.",
"start": 841.39,
"duration": 2.29
},
{
"text": "So how might we handle this\nunordered list in React Native?",
"start": 843.68,
"duration": 5.35
},
{
"text": "So lists, ULs and ordered\nlists don't actually",
"start": 849.03,
"duration": 4.15
},
{
"text": "exist in React Native, and the\nway that we handled those instead",
"start": 853.18,
"duration": 2.89
},
{
"text": "are by using the scrolling\ncomponents because we don't know",
"start": 856.07,
"duration": 6.815
},
{
"text": "how long that list is going\nto get and so we better",
"start": 862.885,
"duration": 2.125
},
{
"text": "assume it's going to get pretty long\nand be able to scroll through them",
"start": 865.01,
"duration": 2.07
},
{
"text": "if we needed.",
"start": 867.08,
"duration": 1.31
},
{
"text": "And so unordered lists we\nreplace with scroll view",
"start": 868.39,
"duration": 4.18
},
{
"text": "and now we have what\nwe were looking for.",
"start": 872.57,
"duration": 3.01
},
{
"text": "So all of the React Native components,\nthe React components sorry,",
"start": 875.58,
"duration": 3.88
},
{
"text": "we've changed to React Native\ncomponents and now we have--",
"start": 879.46,
"duration": 3.388
},
{
"text": "Oops, something's breaking still.",
"start": 882.848,
"duration": 2.322
},
{
"text": "Prompt is another one\nof those browser APIs",
"start": 890.42,
"duration": 3.9
},
{
"text": "that just does not exist in\nthe React Native world which",
"start": 894.32,
"duration": 2.7
},
{
"text": "caused our code to crash.",
"start": 897.02,
"duration": 1.39
},
{
"text": "And so rather than using\none of these browser",
"start": 898.41,
"duration": 2.96
},
{
"text": "APIs let's just replace it with\nsome hard coded text for now,",
"start": 901.37,
"duration": 3.21
},
{
"text": "maybe something like to do, number,\nand then whatever it's ID is.",
"start": 904.58,
"duration": 8.15
},
{
"text": "And rather than\nincrementing ID down there",
"start": 916.511,
"duration": 1.749
},
{
"text": "let's actually increment it up here.",
"start": 918.26,
"duration": 1.5
},
{
"text": "And so now it works.",
"start": 922.51,
"duration": 1.15
},
{
"text": "So we have to do number\none, to do number two",
"start": 923.66,
"duration": 2.42
},
{
"text": "and you can see how we add those.",
"start": 926.08,
"duration": 3.31
},
{
"text": "And so we'll fix the\nstyle in the future,",
"start": 929.39,
"duration": 2.1
},
{
"text": "but basically does\nanybody have questions",
"start": 931.49,
"duration": 2.64
},
{
"text": "on going from React Web to React Native?",
"start": 934.13,
"duration": 3.39
},
{
"text": "What we did there was just replace\nall the React Web components",
"start": 937.52,
"duration": 3.36
},
{
"text": "with the React Native components.",
"start": 940.88,
"duration": 1.89
},
{
"text": "And it is almost as easy as command\neffing and replacing like that.",
"start": 942.77,
"duration": 4.52
},
{
"text": "Great.",
"start": 951.291,
"duration": 0.499
},
{
"text": "And so how are you going to go\nabout styling those components?",
"start": 951.79,
"duration": 3.27
},
{
"text": "So in React Web the way\nwe did that was just",
"start": 955.06,
"duration": 2.9
},
{
"text": "by adding a class name and then\nstyling in CSS, but in React Native",
"start": 957.96,
"duration": 3.89
},
{
"text": "we don't have this concept of CSS.",
"start": 961.85,
"duration": 3.492
},
{
"text": "So the way that React\nNative handles that",
"start": 965.342,
"duration": 1.708
},
{
"text": "is by actually using JavaScript objects\nfor styling and what that gives us",
"start": 967.05,
"duration": 3.33
},
{
"text": "is the ability to use dynamic styles.",
"start": 970.38,
"duration": 4.11
},
{
"text": "Object keys in these objects\nare based on CSS properties,",
"start": 974.49,
"duration": 3.35
},
{
"text": "so we have stuff like margin top,\nmargin bottom, margin padding.",
"start": 977.84,
"duration": 5.726
},
{
"text": "And the layout system\nthat we used is Flexbox",
"start": 983.566,
"duration": 1.874
},
{
"text": "and so, if you're familiar\nwith the Flexbox system in web,",
"start": 985.44,
"duration": 2.416
},
{
"text": "it's almost exactly the\nsame in React Native.",
"start": 987.856,
"duration": 3.104
},
{
"text": "One of the key differences\nis that rather than",
"start": 990.96,
"duration": 3.06
},
{
"text": "defaulting to row we default to\nlaying out things in columns.",
"start": 994.02,
"duration": 7.48
},
{
"text": "So, in React Web, we have this\nconcept of pixels or percentages,",
"start": 1001.5,
"duration": 3.52
},
{
"text": "but in React Native we actually\nuse unit-less numbers for length.",
"start": 1005.02,
"duration": 4.36
},
{
"text": "Which is good because there\nare so many different devices",
"start": 1009.38,
"duration": 3.48
},
{
"text": "that this runs on with\ndifferent pixel densities",
"start": 1012.86,
"duration": 2.19
},
{
"text": "that having a unit-less number allows\nus to abstract that pixel density out.",
"start": 1015.05,
"duration": 4.18
},
{
"text": "The style prop, so the way that\nyou style a given component",
"start": 1022.52,
"duration": 3.72
},
{
"text": "is by assigning that JavaScript\nobject to a style prop",
"start": 1026.24,
"duration": 3.89
},
{
"text": "and it can actually\ntake an array of styles.",
"start": 1030.13,
"duration": 1.87
},
{
"text": "And so, if you wanted to have a bunch\nof different class names in React Web",
"start": 1032.0,
"duration": 3.78
},
{
"text": "you'd just start adding those\nwith a space in between.",
"start": 1035.78,
"duration": 3.6
},
{
"text": "But in React Native you handled\nthat by passing an array of styles.",
"start": 1039.38,
"duration": 3.075
},
{
"text": "So let's go ahead and add styles\nto this app that we have here.",
"start": 1045.109,
"duration": 7.121
},
{
"text": "So first, let's go ahead\nand style this view.",
"start": 1052.23,
"duration": 2.24
},
{
"text": "And so right now, as you see, each\nto do has a Delete button and a",
"start": 1054.47,
"duration": 6.27
},
{
"text": "to do right under it, whereas in web\nwe had the Delete button next to that",
"start": 1060.74,
"duration": 4.24
},
{
"text": "to do.",
"start": 1064.98,
"duration": 0.5
},
{
"text": "And so let's try to\nfigure out exactly how we",
"start": 1065.48,
"duration": 2.32
},
{
"text": "can get that Delete button over\nhere and the to do to be next to it.",
"start": 1067.8,
"duration": 4.7
},
{
"text": "And so does anybody have any ideas\nabout how we might want to do that?",
"start": 1072.5,
"duration": 4.59
},
{
"text": "We know we're going to\nhave to pass a style prop,",
"start": 1077.09,
"duration": 2.43
},
{
"text": "and we know that it's\ngoing to be an object.",
"start": 1079.52,
"duration": 3.45
},
{
"text": "And so this looks weird to\nhave those double curlies",
"start": 1082.97,
"duration": 2.46
},
{
"text": "but the outer curlies\nmean, hey here comes",
"start": 1085.43,
"duration": 2.7
},
{
"text": "some JavaScript and the inner\ncurlies are just an object",
"start": 1088.13,
"duration": 3.06
},
{
"text": "literal like we've seen before.",
"start": 1091.19,
"duration": 2.88
},
{
"text": "And so how might we get\nthose to dos to be in a row?",
"start": 1094.07,
"duration": 3.61
},
{
"text": "So we saw before that React Native uses\nFlexbox in order to handle it's layout.",
"start": 1100.35,
"duration": 6.81
},
{
"text": "And so we can just say, hey we want\nthe flex direction, rather than being",
"start": 1107.16,
"duration": 6.63
},
{
"text": "column by default, let's set it to row.",
"start": 1113.79,
"duration": 2.818
},
{
"text": "And so now we have the Delete\nbutton next to the to do.",
"start": 1119.42,
"duration": 5.19
},
{
"text": "But it's annoying me a little bit how\nthat button is slightly below the text.",
"start": 1124.61,
"duration": 5.77
},
{
"text": "And so how might we get those\nitems to be aligned to center?",
"start": 1130.38,
"duration": 5.36
},
{
"text": "Well in Flexbox we have this\nthing called align items",
"start": 1135.74,
"duration": 6.12
},
{
"text": "and then you just say, hey\nalign those to be center.",
"start": 1141.86,
"duration": 3.66
},
{
"text": "Then all of a sudden we\nhave it aligned center.",
"start": 1145.52,
"duration": 2.27
},
{
"text": "And just confirming that\ndelete button does indeed work.",
"start": 1151.55,
"duration": 3.841
},
{
"text": "Great.",
"start": 1155.391,
"duration": 0.499
},
{
"text": "Anybody notice any other\nbad style bugs over here?",
"start": 1155.89,
"duration": 3.45
},
{
"text": "So look at this.",
"start": 1161.89,
"duration": 3.25
},
{
"text": "So most phones will have some\nnav bar, and that nav bar",
"start": 1165.14,
"duration": 5.72
},
{
"text": "will have stuff like if you're\nconnected to Wi-Fi, the time and etc.",
"start": 1170.86,
"duration": 3.87
},
{
"text": "But that first view is actually\ngoing all the way to the top.",
"start": 1174.73,
"duration": 3.95
},
{
"text": "And so how might we get all this\ncontent to be slightly moved down?",
"start": 1178.68,
"duration": 3.46
},
{
"text": "So how would we do that in Web?",
"start": 1186.29,
"duration": 2.75
},
{
"text": "AUDIENCE: Add a margin.",
"start": 1189.04,
"duration": 1.98
},
{
"text": "SPEAKER 1: Yeah we would add a\nmargin or some padding or something",
"start": 1191.02,
"duration": 2.75
},
{
"text": "to move the content from\nthe top slightly down.",
"start": 1193.77,
"duration": 4.09
},
{
"text": "And so we could do that\nin React Native as well.",
"start": 1197.86,
"duration": 3.68
},
{
"text": "So you can say with this view, let's\nactually put a padding on the top",
"start": 1201.54,
"duration": 7.57
},
{
"text": "and let's just say something like\n50 which is somewhat arbitrary.",
"start": 1209.11,
"duration": 4.741
},
{
"text": "And now we've gone ahead and\nmoved that down slightly.",
"start": 1213.851,
"duration": 2.249
},
{
"text": "But what if we wanted to move it down\nexactly the same amount as the status",
"start": 1219.46,
"duration": 6.08
},
{
"text": "bar?",
"start": 1225.54,
"duration": 0.5
},
{
"text": "Well there's this great\ntool called Expo which",
"start": 1228.96,
"duration": 2.85
},
{
"text": "we'll talk about in length later today.",
"start": 1231.81,
"duration": 1.84
},
{
"text": "They're also the people\nwho designed Snack.",
"start": 1233.65,
"duration": 2.3
},
{
"text": "And they actually give you\nthis thing called constant",
"start": 1235.95,
"duration": 2.61
},
{
"text": "so we can do import constants from Expo.",
"start": 1238.56,
"duration": 3.515
},
{
"text": "And we can actually say,\nhey padding top rather",
"start": 1245.56,
"duration": 2.2
},
{
"text": "than assigning an arbitrary value of\n50 let's do constants.statusbarheight",
"start": 1247.76,
"duration": 8.76
},
{
"text": "and that will actually give you\nthat exact status bar height",
"start": 1256.52,
"duration": 4.05
},
{
"text": "even if you're on different phones.",
"start": 1260.57,
"duration": 2.174
},
{
"text": "And so, again, we'll\ntalk about Expo and we'll",
"start": 1262.744,
"duration": 1.916
},
{
"text": "talk about importing and\nexporting later today.",
"start": 1264.66,
"duration": 3.17
},
{
"text": "But just FYI there's this thing called\nconstants.statusbarheight which will",
"start": 1267.83,
"duration": 3.99
},
{
"text": "give us exactly that status bar height.",
"start": 1271.82,
"duration": 2.67
},
{
"text": "And now we have a to do app\nthat doesn't look half bad.",
"start": 1274.49,
"duration": 3.14
},
{
"text": "Cool.",
"start": 1277.63,
"duration": 0.5
},
{
"text": "So there's actually this\nthing called style sheet",
"start": 1278.13,
"duration": 2.27
},
{
"text": "which is part of React Native which has\nsome optimizations for these styles.",
"start": 1280.4,
"duration": 5.91
},
{
"text": "And so we talked about earlier how the\nway that your JavaScript communicates",
"start": 1286.31,
"duration": 4.11
},
{
"text": "with the UI throughout\nis through this bridge.",
"start": 1290.42,
"duration": 3.65
},
{
"text": "And so that means every single\ntime you want a view with the style",
"start": 1294.07,
"duration": 3.46
},
{
"text": "you need to send those style\nattributes over the bridge.",
"start": 1297.53,
"duration": 2.7
},
{
"text": "There's actually a way\nthat you can optimize this.",
"start": 1300.23,
"duration": 2.13
},
{
"text": "And so the Facebook team\ncreated this thing called",
"start": 1302.36,
"duration": 2.083
},
{
"text": "style sheet which does this for you.",
"start": 1304.443,
"duration": 1.967
},
{
"text": "So it's basically the same thing\nas creating objects for style,",
"start": 1306.41,
"duration": 2.67
},
{
"text": "but as an additional optimization that\nrather than sending this style object",
"start": 1309.08,
"duration": 5.04
},
{
"text": "over the bridge we can only send IDs.",
"start": 1314.12,
"duration": 2.55
},
{
"text": "And so say we have these objects,\nrather than passing the full object",
"start": 1316.67,
"duration": 6.78
},
{
"text": "every time you can just\nsay, hey this object,",
"start": 1323.45,
"duration": 1.925
},
{
"text": "let's assign it this\narbitrary ID of one.",
"start": 1325.375,
"duration": 2.215
},
{
"text": "And so every time we say, hey\nthis should have a style of one,",
"start": 1327.59,
"duration": 4.72
},
{
"text": "the UI thread will know, oh, I\nknow exactly what style that means.",
"start": 1332.31,
"duration": 4.11
},
{
"text": "And so to do that, all we have to do\nis import this thing called style sheet",
"start": 1336.42,
"duration": 6.26
},
{
"text": "from React Native and we can do this.",
"start": 1342.68,
"duration": 1.77
},
{
"text": "And so we're saying we're declaring our\nstyles as a constant outside of our app",
"start": 1351.83,
"duration": 5.42
},
{
"text": "and we're saying, hey\ncreate this style sheet",
"start": 1357.25,
"duration": 2.64
},
{
"text": "and we're going to pass into\nyou an object where the keys map",
"start": 1359.89,
"duration": 2.55
},
{
"text": "with how we're going to use this later.",
"start": 1362.44,
"duration": 3.676
},
{
"text": "And so we can go ahead\nand abstract this out.",
"start": 1366.116,
"duration": 1.874
},
{
"text": "And so we can say, this\nhere we're actually",
"start": 1367.99,
"duration": 4.38
},
{
"text": "going to call our to do container.",
"start": 1372.37,
"duration": 3.995
},
{
"text": "And our to do container will just say,\nall right flex in the row direction",
"start": 1380.085,
"duration": 7.165
},
{
"text": "and align your items to be centered.",
"start": 1387.25,
"duration": 2.922
},
{
"text": "And then down here\nfor style we just say,",
"start": 1390.172,
"duration": 1.708
},
{
"text": "oh, we want to use styles.todocontainer.",
"start": 1391.88,
"duration": 1.73
},
{
"text": "And let's actually lowercase\nthis for convention.",
"start": 1397.42,
"duration": 5.04
},
{
"text": "And as you can see those\nstyles still get applied.",
"start": 1402.46,
"duration": 3.86
},
{
"text": "And why else might this pattern be good?",
"start": 1406.32,
"duration": 3.34
},
{
"text": "Does anybody see something\nbetter about this pattern?",
"start": 1409.66,
"duration": 2.37
},
{
"text": "AUDIENCE: It's reusable.",
"start": 1415.229,
"duration": 1.831
},
{
"text": "SPEAKER 1: Yeah exactly, it's reusable.",
"start": 1417.06,
"duration": 3.21
},
{
"text": "And so say we wanted to\nhave something else that",
"start": 1420.27,
"duration": 2.94
},
{
"text": "had very similar styles\nto to do container",
"start": 1423.21,
"duration": 5.49
},
{
"text": "we can actually use that again.",
"start": 1428.7,
"duration": 1.299
},
{
"text": "And then if we wanted to change\nboth of them at the same time",
"start": 1429.999,
"duration": 2.541
},
{
"text": "we could do it by using\nthis abstracted out object.",
"start": 1432.54,
"duration": 2.94
},
{
"text": "And so let's do the app container\nand set that equal to this object.",
"start": 1435.48,
"duration": 7.66
},
{
"text": "And then down here for this view\nlet's do styles.appcontainer.",
"start": 1451.27,
"duration": 3.75
},
{
"text": "And so there's actually an\neven better reason to do this",
"start": 1458.61,
"duration": 4.99
},
{
"text": "and it's because every\nsingle time we rendered,",
"start": 1463.6,
"duration": 2.29
},
{
"text": "we used to be building a\nnew style object to pass.",
"start": 1465.89,
"duration": 2.87
},
{
"text": "And now we're just using\nthat same reference",
"start": 1468.76,
"duration": 2.13
},
{
"text": "to that object that we created\noutside of this component.",
"start": 1470.89,
"duration": 3.81
},
{
"text": "And so that's just an additional\noptimization that, using this pattern,",
"start": 1474.7,
"duration": 4.99
},
{
"text": "creating the styles outside of\nthe component allows us to do.",
"start": 1479.69,
"duration": 3.14
},
{
"text": "Cool.",
"start": 1485.56,
"duration": 2.19
},
{
"text": "Any questions on styles and styling?",
"start": 1487.75,
"duration": 3.68
},
{
"text": "Great.",
"start": 1491.43,
"duration": 0.5
},
{
"text": "So let's talk about event handling.",
"start": 1494.69,
"duration": 2.53
},
{
"text": "So unlike Web not every component\nhas every single interaction.",
"start": 1497.22,
"duration": 3.71
},
{
"text": "And so in Web, if we had a div, we\ncan assign an onClick to that div",
"start": 1500.93,
"duration": 3.24
},
{
"text": "or if we add a list item or a list,\nanything we can assign an onClick to.",
"start": 1504.17,
"duration": 4.23
},
{
"text": "But unlike Web there are only a few\ntouchable components in React Native",
"start": 1508.4,
"duration": 3.48
},
{
"text": "and those are a button,\nwhich we've used before.",
"start": 1511.88,
"duration": 3.469
},
{
"text": "These three things called touchable\nopacity, touchable highlight",
"start": 1515.349,
"duration": 2.666
},
{
"text": "and touchable without\nfeedback, which are just",
"start": 1518.015,
"duration": 4.436
},
{
"text": "three basic components that have\nslightly different reactions when",
"start": 1522.451,
"duration": 2.749
},
{
"text": "you touch them.",
"start": 1525.2,
"duration": 1.292
},
{
"text": "An then lastly, this thing\ncalled touchable native feedback",
"start": 1526.492,
"duration": 2.458
},
{
"text": "which is this native component\nthat you can only use on Android.",
"start": 1528.95,
"duration": 4.09
},
{
"text": "And so in Web, when you\nhad an event handler,",
"start": 1536.33,
"duration": 3.36
},
{
"text": "that handler would receive\nthat event as an argument.",
"start": 1539.69,
"duration": 2.87
},
{
"text": "But that's not necessarily true\nfor all React Native handlers.",
"start": 1542.56,
"duration": 5.88
},
{
"text": "And so in order just to\nfind out how those work",
"start": 1548.44,
"duration": 2.57
},
{
"text": "you basically have to\nconsult the documentation.",
"start": 1551.01,
"duration": 2.57
},
{
"text": "The documentation for React\nNative is really good.",
"start": 1553.58,
"duration": 2.14
},
{
"text": "I recommend that you\nperuse them just to see",
"start": 1555.72,
"duration": 2.03
},
{
"text": "what components are available\nto you and those component APIs.",
"start": 1557.75,
"duration": 3.92
},
{
"text": "And basically most of the\nstuff that you want to do",
"start": 1561.67,
"duration": 3.25
},
{
"text": "is already pre-built for you.",
"start": 1564.92,
"duration": 1.742
},
{
"text": "And so, even though\nthere's no such thing",
"start": 1566.662,
"duration": 1.708
},
{
"text": "as a checkbox component in React Native,\nthere is actually a way to do that.",
"start": 1568.37,
"duration": 4.82
},
{
"text": "And so let's go ahead\nand add this thing which",
"start": 1573.19,
"duration": 2.65
},
{
"text": "is similar to a checkbox\nin that it's a Boolean flag",
"start": 1575.84,
"duration": 4.47
},
{
"text": "but it's not really exactly\nstylistically the same.",
"start": 1580.31,
"duration": 3.462
},
{
"text": "And so let's add this\nthing called a switch.",
"start": 1583.772,
"duration": 1.833
},
{
"text": "As a switch you'll see what\nit looks like in a moment",
"start": 1589.082,
"duration": 3.428
},
{
"text": "but it's basically just a Boolean flag\nthat we're going to use in this example",
"start": 1592.51,
"duration": 3.487
},
{
"text": "rather than using a checkbox.",
"start": 1595.997,
"duration": 1.208
},
{
"text": "So before what we had here was an\ninput of type checkbox and instead",
"start": 1600.94,
"duration": 4.04
},
{
"text": "we're going to use a switch.",
"start": 1604.98,
"duration": 2.26
},
{
"text": "And the value of that is going to be\nwhether the props.TODO is checked.",
"start": 1607.24,
"duration": 5.21
},
{
"text": "And so now when we add\na TODO we see the switch",
"start": 1616.7,
"duration": 2.4
},
{
"text": "that can be flipped back and forth.",
"start": 1619.1,
"duration": 2.41
},
{
"text": "But if you notice, every\ntime I try to flip it on it",
"start": 1621.51,
"duration": 2.81
},
{
"text": "immediately turns back off.",
"start": 1624.32,
"duration": 3.15
},
{
"text": "Can anybody spot why that's happening?",
"start": 1627.47,
"duration": 2.7
},
{
"text": "So we have this value set to props.TODO\nchecked, and down here do we ever",
"start": 1634.97,
"duration": 7.25
},
{
"text": "update that value?",
"start": 1642.22,
"duration": 0.934
},
{
"text": "No we don't.",
"start": 1645.76,
"duration": 0.81
},
{
"text": "So we have this thing called Toggle\nTODO which we implemented last week,",
"start": 1646.57,
"duration": 3.93
},
{
"text": "which, given some TODOs ID will\nflip that Boolean checked flag.",
"start": 1650.5,
"duration": 4.93
},
{
"text": "But we never actually hook\nthat up for this example.",
"start": 1655.43,
"duration": 4.53
},
{
"text": "So in the TODO component here\nwe're passing down an onToggle prop",
"start": 1659.96,
"duration": 4.97
},
{
"text": "but we never actually use it up here.",
"start": 1664.93,
"duration": 2.52
},
{
"text": "And so here we should actually\nhave the switch when we do on--",
"start": 1667.45,
"duration": 7.65
},
{
"text": "what's it called-- on value change.",
"start": 1675.1,
"duration": 3.02
},
{
"text": "And I only know this because\nthat's what the documentation says.",
"start": 1678.12,
"duration": 4.06
},
{
"text": "And so when that value changed,\nI should run props.onToggle,",
"start": 1682.18,
"duration": 6.18
},
{
"text": "which is the name of the\nprop that we're passing down",
"start": 1688.36,
"duration": 3.03
},
{
"text": "from this parent component.",
"start": 1691.39,
"duration": 1.95
},
{
"text": "And so now when we\nclick TODO it updates.",
"start": 1693.34,
"duration": 4.25
},
{
"text": "And as you see right here the unchecked\nTODO count still updates as expected.",
"start": 1697.59,
"duration": 5.664
},
{
"text": "And so now if we create a bunch\nwe can see those numbers changing.",
"start": 1703.254,
"duration": 3.986
},
{
"text": "We can see the checking and\ntoggling works as expected.",
"start": 1707.24,
"duration": 2.75
},
{
"text": "We see if we delete this\none the TODO count goes down",
"start": 1709.99,
"duration": 2.43
},
{
"text": "but the uncheck count does not\ngo down since it was checked.",
"start": 1712.42,
"duration": 2.704
},
{
"text": "If we delete something that isn't\nchecked, both of them go down.",
"start": 1715.124,
"duration": 2.666
},
{
"text": "And so we have the same behavior as\nwe did in our React Web application.",
"start": 1717.79,
"duration": 5.917
},
{
"text": "Any questions there?",
"start": 1728.58,
"duration": 1.18
},
{
"text": "So we have this being a scroll view.",
"start": 1735.2,
"duration": 2.73
},
{
"text": "But, if you notice, the\nscroll view gets cut off early",
"start": 1737.93,
"duration": 2.77
},
{
"text": "and as we add TODOs it grows.",
"start": 1740.7,
"duration": 4.23
},
{
"text": "But if we add a bunch of\nTODOs it grows with it.",
"start": 1744.93,
"duration": 11.59
},
{
"text": "But say we actually wanted the scroll\nview to reach all the way to the bottom",
"start": 1756.52,
"duration": 6.54
},
{
"text": "no matter how many TODOs were there.",
"start": 1763.06,
"duration": 2.25
},
{
"text": "Does anybody know how we\nmay go about doing that?",
"start": 1765.31,
"duration": 3.37
},
{
"text": "The hint being that in order\nto control layout what we use",
"start": 1768.68,
"duration": 2.687
},
{
"text": "is this thing called Flexbox.",
"start": 1771.367,
"duration": 1.208
},
{
"text": "So by default components\nwill grow to however big",
"start": 1775.66,
"duration": 4.83
},
{
"text": "they need to be in order\nto fit their children.",
"start": 1780.49,
"duration": 3.48
},
{
"text": "But we have a way of saying, hey fill\nas much space as you possibly can.",
"start": 1783.97,
"duration": 4.69
},
{
"text": "And the way to do that\nis saying flex: 1.",
"start": 1788.66,
"duration": 3.65
},
{
"text": "And so we want the app container\nto have a flex value of 1",
"start": 1792.31,
"duration": 3.94
},
{
"text": "so that the app container\nfills up all possible space.",
"start": 1796.25,
"duration": 4.4
},
{
"text": "And so we could do something like\napp container let's do flex: 1.",
"start": 1800.65,
"duration": 4.59
},
{
"text": "And then maybe for the TODOs,\nthe scroll view here, maybe we",
"start": 1805.24,
"duration": 5.67
},
{
"text": "want that to fill as well.",
"start": 1810.91,
"duration": 1.97
},
{
"text": "And so we could go\ndown to the scroll view",
"start": 1812.88,
"duration": 2.74
},
{
"text": "and say the style is\ngoing to be flex: 1.",
"start": 1815.62,
"duration": 5.61
},
{
"text": "But that isn't great design.",
"start": 1821.23,
"duration": 2.61
},
{
"text": "What if we wanted instead to just have\na style called Fill, which will just",
"start": 1823.84,
"duration": 5.43
},
{
"text": "fill whatever space is available.",
"start": 1829.27,
"duration": 2.49
},
{
"text": "And so that would be a\ngood abstraction to have.",
"start": 1831.76,
"duration": 2.772
},
{
"text": "So here we have a TODO container,\nwe have an app container,",
"start": 1834.532,
"duration": 2.458
},
{
"text": "and let's actually create this style\ncalled Fill, which we'll just flex: 1.",
"start": 1836.99,
"duration": 4.37
},
{
"text": "And so now we can say hey, we\nwant this scroll view to fill",
"start": 1845.8,
"duration": 9.34
},
{
"text": "and we also want our\napp container to fill.",
"start": 1855.14,
"duration": 5.37
},
{
"text": "But instead of adding\nthat to app container,",
"start": 1860.51,
"duration": 3.23
},
{
"text": "what would be a better way to do it?",
"start": 1863.74,
"duration": 1.78
},
{
"text": "Well, we can actually\napply both those styles.",
"start": 1865.52,
"duration": 1.98
},
{
"text": "Does anybody remember how we could\ndo that, apply multiple styles",
"start": 1867.5,
"duration": 3.09
},
{
"text": "to the same component?",
"start": 1870.59,
"duration": 1.666
},
{
"text": "So in React Web we would actually\njust give it multiple classes.",
"start": 1875.68,
"duration": 4.49
},
{
"text": "What is the analog in React Native?",
"start": 1880.17,
"duration": 1.64
},
{
"text": "We can actually just pass an array.",
"start": 1884.88,
"duration": 2.18
},
{
"text": "And so say first apply\nstyles.Appcontainer and then apply",
"start": 1887.06,
"duration": 3.58
},
{
"text": "styles.fill.",
"start": 1890.64,
"duration": 0.75
},
{
"text": "And now, if we add a\nbunch of TODOs we can",
"start": 1894.63,
"duration": 4.23
},
{
"text": "see that it fills the available space.",
"start": 1898.86,
"duration": 2.4
},
{
"text": "And then if we delete TODOs such that\nit doesn't fill the available space",
"start": 1901.26,
"duration": 3.96
},
{
"text": "we see that it's not getting\ncut off at the bottom",
"start": 1905.22,
"duration": 3.06
},
{
"text": "because it's filling all the way\ndown to the bottom of this container.",
"start": 1908.28,
"duration": 5.64
},
{
"text": "So any questions on event\nhandling, styling or moving",
"start": 1913.92,
"duration": 4.92
},
{
"text": "React Web to React Native components?",
"start": 1918.84,
"duration": 2.355
},
{
"text": "No.",
"start": 1923.925,
"duration": 1.301
},
{
"text": "So we've been talking about\nthis thing called components,",
"start": 1925.226,
"duration": 2.374
},
{
"text": "but we haven't really dived too\ndeeply into what that really means.",
"start": 1927.6,
"duration": 4.5
},
{
"text": "In the past few weeks, we've\ntalked about how components",
"start": 1932.1,
"duration": 2.61
},
{
"text": "return a node, how they\nrepresent a discrete piece of UI,",
"start": 1934.71,
"duration": 3.08
},
{
"text": "how all components should act like pure\nfunctions with respect to their props.",
"start": 1937.79,
"duration": 4.01
},
{
"text": "But that's really where we\nstopped talking about components.",
"start": 1941.8,
"duration": 2.69
},
{
"text": "And so this week, we're going to\ndive more deeply into components",
"start": 1944.49,
"duration": 2.73
},
{
"text": "and what components actually are.",
"start": 1947.22,
"duration": 2.797
},
{
"text": "And so there are actually\ntwo types of components.",
"start": 1950.017,
"duration": 2.083
},
{
"text": "And we've actually seen\nboth of them already.",
"start": 1952.1,
"duration": 2.05
},
{
"text": "So first is this thing called a\nstateless functional component.",
"start": 1954.15,
"duration": 2.92
},
{
"text": "You might see it abbreviated as SFC or\nif you're reading blog posts online,",
"start": 1957.07,
"duration": 3.38
},
{
"text": "some people call them pure\nfunctional components.",
"start": 1960.45,
"duration": 2.95
},
{
"text": "And what those are\nbasically just functions.",
"start": 1963.4,
"duration": 3.65
},
{
"text": "So something like this\nTODO that we've created",
"start": 1967.05,
"duration": 3.06
},
{
"text": "is just a function that takes\nin props and returns some node.",
"start": 1970.11,
"duration": 3.72
},
{
"text": "It has no concept of state.",
"start": 1973.83,
"duration": 2.676
},
{
"text": "And so that's why it's called a\nstateless functional component.",
"start": 1976.506,
"duration": 2.624
},
{
"text": "It's just a function with no state.",
"start": 1979.13,
"duration": 2.41
},
{
"text": "And the second is a\nreact.component which",
"start": 1984.09,
"duration": 1.86
},
{
"text": "we've been extending from but we\nhaven't really talked about it",
"start": 1985.95,
"duration": 3.21
},
{
"text": "too far in depth.",
"start": 1989.16,
"duration": 1.91
},
{
"text": "And so first let's talk about\nstateless functional components.",
"start": 1991.07,
"duration": 3.041
},
{
"text": "So this is the simplest\ntype of component.",
"start": 1999.03,
"duration": 2.21
},
{
"text": "You should use this when\nyou don't need any state.",
"start": 2001.24,
"duration": 3.24
},
{
"text": "And what it is is a function that\ntakes props and returns a node.",
"start": 2004.48,
"duration": 4.04
},
{
"text": "And it shouldn't do anything other\nthan taking props and return a node.",
"start": 2008.52,
"duration": 3.34
},
{
"text": "It should be what's\ncalled a pure function.",
"start": 2011.86,
"duration": 1.999
},
{
"text": "In other words, it should not have\nany side effects, like setting a value",
"start": 2013.859,
"duration": 3.041
},
{
"text": "or pushing to an array, updating\nan object, something like that",
"start": 2016.9,
"duration": 4.86
},
{
"text": "because it should just take\nin props and return the value.",
"start": 2021.76,
"duration": 4.2
},
{
"text": "If you do stuff other than that you\nmight create some bugs or even worse",
"start": 2025.96,
"duration": 5.4
},
{
"text": "crash your app or something like that.",
"start": 2031.36,
"duration": 3.264
},
{
"text": "Then, any changes to the\nprops that you passed",
"start": 2034.624,
"duration": 1.916
},
{
"text": "to a stateless functional\ncomponent will automatically",
"start": 2036.54,
"duration": 2.68
},
{
"text": "cause that function to be re-invoked.",
"start": 2039.22,
"duration": 2.65
},
{
"text": "And then after it re-invokes\nthe function and returns nodes,",
"start": 2041.87,
"duration": 3.2
},
{
"text": "React will do its thing and compare\nnodes to what it has in its virtual dom",
"start": 2045.07,
"duration": 4.407
},
{
"text": "and then go ahead and\nreplace what's needed.",
"start": 2049.477,
"duration": 1.833
},
{
"text": "And so on the other side of the coin,\nwe have what's called a React.component.",
"start": 2054.06,
"duration": 3.966
},
{
"text": "This is something that's actually\nprovided by the React library",
"start": 2058.026,
"duration": 2.624
},
{
"text": "and implemented for you.",
"start": 2060.65,
"duration": 1.68
},
{
"text": "And it's an abstract class that can be\nextended to behave however you want.",
"start": 2062.33,
"duration": 3.82
},
{
"text": "And so, in our example\nhere and examples prior,",
"start": 2066.15,
"duration": 3.299
},
{
"text": "we've been doing this thing where we\ncreate a class called whatever we want",
"start": 2069.449,
"duration": 3.421
},
{
"text": "and we're actually extending this\nthing called a React component.",
"start": 2072.87,
"duration": 4.53
},
{
"text": "And so what is a React.component?",
"start": 2077.4,
"duration": 3.981
},
{
"text": "Well these things have\nadditional features",
"start": 2081.381,
"duration": 1.749
},
{
"text": "that stateless functional\ncomponents do not.",
"start": 2083.13,
"duration": 2.46
},
{
"text": "One of those, of course, is that they\nhave instances so they're a class.",
"start": 2085.59,
"duration": 3.247
},
{
"text": "And so when you invoke that\nclass it returns an instance",
"start": 2088.837,
"duration": 2.333
},
{
"text": "and that instance will persist\nthroughout the lifetime of this class.",
"start": 2091.17,
"duration": 5.719
},
{
"text": "As suggested by the name,\nit maintains its own state",
"start": 2096.889,
"duration": 3.341
},
{
"text": "and so stateless components do not,\nwhereas these React components do.",
"start": 2100.23,
"duration": 4.62
},
{
"text": "They have this concept of\nstate, and we talked about state",
"start": 2104.85,
"duration": 2.58
},
{
"text": "in depth last lecture.",
"start": 2107.43,
"duration": 0.96
},
{
"text": "One thing we didn't\ntalk about last lecture",
"start": 2111.399,
"duration": 1.791
},
{
"text": "is this thing called a lifecycle,\nit's lifecycle methods.",
"start": 2113.19,
"duration": 3.395
},
{
"text": "And so these are similar\nto hooks or event handlers.",
"start": 2116.585,
"duration": 2.595
},
{
"text": "And so we've used the event handlers\nbefore in both React Web and React",
"start": 2119.18,
"duration": 4.17
},
{
"text": "Native.",
"start": 2123.35,
"duration": 1.29
},
{
"text": "And these things are actually\nautomatically invoked for you.",
"start": 2124.64,
"duration": 2.56
},
{
"text": "You don't have to worry about\nexactly the implementation details",
"start": 2127.2,
"duration": 3.65
},
{
"text": "or when to invoke your own functions.",
"start": 2130.85,
"duration": 1.9
},
{
"text": "That's actually something\nthat's done automatically.",
"start": 2132.75,
"duration": 4.13
},
{
"text": "And so unlike stateless\nfunctional components,",
"start": 2136.88,
"duration": 2.43
},
{
"text": "which just take props and return a\nnode, a React components render function",
"start": 2139.31,
"duration": 4.68
},
{
"text": "actually becomes a function of\nthe props and also any class",
"start": 2143.99,
"duration": 3.06
},
{
"text": "properties that exist.",
"start": 2147.05,
"duration": 1.06
},
{
"text": "And so if you remember back to last\nlecture we talked about classes",
"start": 2148.11,
"duration": 3.44
},
{
"text": "and how when you create\na class instance,",
"start": 2151.55,
"duration": 1.96
},
{
"text": "you might attach to it some properties.",
"start": 2153.51,
"duration": 2.1
},
{
"text": "These properties can be\nvalues anywhere from functions",
"start": 2155.61,
"duration": 3.23
},
{
"text": "to just primitives, objects.",
"start": 2158.84,
"duration": 3.78
},
{
"text": "And so when you create a\nclass component instance,",
"start": 2162.62,
"duration": 3.19
},
{
"text": "you can actually use all of those\nclass properties in that render method.",
"start": 2165.81,
"duration": 5.85
},
{
"text": "And so we saw that over here\nwhen we created this addTODO",
"start": 2171.66,
"duration": 7.04
},
{
"text": "where within the render we referenced\nthis.addTODO in this button component",
"start": 2178.7,
"duration": 6.99
},
{
"text": "here.",
"start": 2185.69,
"duration": 1.401
},
{
"text": "And so, as you see, this is a\nclass property which we actually",
"start": 2187.091,
"duration": 3.249
},
{
"text": "used in our render method.",
"start": 2190.34,
"duration": 1.56
},
{
"text": "And so this render method is\nactually a function of both props",
"start": 2191.9,
"duration": 4.29
},
{
"text": "and any class properties like its\nstate or these methods that we defined.",
"start": 2196.19,
"duration": 5.33
},
{
"text": "Cool.",
"start": 2204.72,
"duration": 0.5
},
{
"text": "So I talked about this thing\ncalled a lifecycle method,",
"start": 2205.22,
"duration": 2.74
},
{
"text": "but what actually is\na component lifecycle.",
"start": 2207.96,
"duration": 3.08
},
{
"text": "And so a component lifecycle can\nactually be represented by this graph.",
"start": 2211.04,
"duration": 3.89
},
{
"text": "And so first a component will\nmount and so some lifecycle hooks",
"start": 2214.93,
"duration": 4.48
},
{
"text": "get called there, but that's\nbasically that constructor where",
"start": 2219.41,
"duration": 4.06
},
{
"text": "the class instance gets created and\nmaybe its state gets instantiated.",
"start": 2223.47,
"duration": 5.48
},
{
"text": "And then what it does is it renders.",
"start": 2228.95,
"duration": 2.4
},
{
"text": "It will just put you to the page.",
"start": 2231.35,
"duration": 3.03
},
{
"text": "And then every time we call set\nstate or get new props we actually",
"start": 2234.38,
"duration": 3.21
},
{
"text": "enter what's called an update cycle.",
"start": 2237.59,
"duration": 1.78
},
{
"text": "And so when you receive new props,\nthe component needs to update.",
"start": 2239.37,
"duration": 2.97
},
{
"text": "It needs to re-render.",
"start": 2242.34,
"duration": 1.44
},
{
"text": "And so part of its lifecycle is\nactually updating over and over.",
"start": 2243.78,
"duration": 3.69
},
{
"text": "And this happens any time new props\nget received because it wouldn't really",
"start": 2247.47,
"duration": 3.53
},
{
"text": "make sense if we had\na component that when",
"start": 2251.0,
"duration": 2.13
},
{
"text": "it received new props nothing changed.",
"start": 2253.13,
"duration": 2.61
},
{
"text": "But also this update cycle happens\nevery single time the state changes.",
"start": 2255.74,
"duration": 3.88
},
{
"text": "So if you call this .setstate, you\nupdate state and presumably you have",
"start": 2259.62,
"duration": 4.19
},
{
"text": "something in the UI that also updates.",
"start": 2263.81,
"duration": 1.74
},
{
"text": "And so this update\ncycle will happen again.",
"start": 2265.55,
"duration": 2.04
},
{
"text": "And every single time you update state,\nreceive new props this update cycle",
"start": 2267.59,
"duration": 3.43
},
{
"text": "will fire again.",
"start": 2271.02,
"duration": 1.67
},
{
"text": "And then, when it's time for\nthat component to disappear,",
"start": 2272.69,
"duration": 2.96
},
{
"text": "it enters what's called\nthe unmount stage where",
"start": 2275.65,
"duration": 3.91
},
{
"text": "you have the chance to\nclean up anything that you",
"start": 2279.56,
"duration": 3.0
},
{
"text": "may have created during that lifecycle.",
"start": 2282.56,
"duration": 4.44
},
{
"text": "And so what actually does\nthat mean in practice?",
"start": 2287.0,
"duration": 3.652
},
{
"text": "So I said that there's\nthis thing called mount,",
"start": 2290.652,
"duration": 1.958
},
{
"text": "which is basically\njust a series of steps",
"start": 2292.61,
"duration": 2.04
},
{
"text": "that happens when a component\nfirst gets mounted and rendered.",
"start": 2294.65,
"duration": 3.189
},
{
"text": "And so the first thing that happens\nis the constructor gets called.",
"start": 2297.839,
"duration": 2.791
},
{
"text": "And so, as we saw a few lectures\nago when we talked about classes,",
"start": 2300.63,
"duration": 3.35
},
{
"text": "the constructor is where we have\na chance to add class properties",
"start": 2303.98,
"duration": 4.11
},
{
"text": "or add anything to that\ninstance that we need.",
"start": 2308.09,
"duration": 3.3
},
{
"text": "And so here we might want to\ndo stuff like initialize state",
"start": 2311.39,
"duration": 2.52
},
{
"text": "or maybe add some other class\nproperties like bound methods et cetera.",
"start": 2313.91,
"duration": 5.52
},
{
"text": "Next what happens is we render, which\nis just the meat of the component.",
"start": 2319.43,
"duration": 5.33
},
{
"text": "The main goal of any\ncomponent is to show you why.",
"start": 2324.76,
"duration": 4.24
},
{
"text": "And so, in this render method,\nthat's exactly what happens.",
"start": 2329.0,
"duration": 4.08
},
{
"text": "You take any properties that you have,\nany class properties that you have,",
"start": 2333.08,
"duration": 4.66
},
{
"text": "and then you end up returning a node.",
"start": 2337.74,
"duration": 3.209
},
{
"text": "And then after that this hook,\nthat we haven't seen yet, gets",
"start": 2340.949,
"duration": 2.541
},
{
"text": "called a component div mount.",
"start": 2343.49,
"duration": 1.646
},
{
"text": "And this is the chance\nfor you to do anything",
"start": 2345.136,
"duration": 1.874
},
{
"text": "that you wanted to do that\ndidn't really matter for render.",
"start": 2347.01,
"duration": 4.285
},
{
"text": "And so if you have asynched actions,\nlike standing network or passes.",
"start": 2351.295,
"duration": 2.875
},
{
"text": "If you want to add timers\nand stuff like that this",
"start": 2354.17,
"duration": 3.57
},
{
"text": "is exactly where you should do that.",
"start": 2357.74,
"duration": 3.31
},
{
"text": "And then maybe you'll need to\nupdate the state accordingly.",
"start": 2361.05,
"duration": 3.32
},
{
"text": "And so if you actually\nsee that state here",
"start": 2364.37,
"duration": 2.01
},
{
"text": "this will cause a re-render\nwithout updating the UI.",
"start": 2366.38,
"duration": 2.36
},
{
"text": "And so all of this will happen\nbefore the UI re-renders.",
"start": 2368.74,
"duration": 3.57
},
{
"text": "And so let's play with\nthat a little bit.",
"start": 2372.31,
"duration": 2.89
},
{
"text": "So first let's copy this,\nthat way you can keep it.",
"start": 2375.2,
"duration": 3.81
},
{
"text": "So let's clear all of this and then\nplay with mounting a little bit.",
"start": 2389.01,
"duration": 8.76
},
{
"text": "And so in your next project what\nyou're going to do is you're",
"start": 2397.77,
"duration": 3.27
},
{
"text": "going to be implementing\nwhat's called a Pomodoro timer.",
"start": 2401.04,
"duration": 3.76
},
{
"text": "And so for those of you who\nare aware of what those are--",
"start": 2404.8,
"duration": 3.47
},
{
"text": "basically what it is is\na timer that allows you",
"start": 2408.27,
"duration": 3.06
},
{
"text": "to switch between two amounts of time.",
"start": 2411.33,
"duration": 3.069
},
{
"text": "And so there's this thing called\nthe Pomodoro Technique which",
"start": 2414.399,
"duration": 2.541
},
{
"text": "is used for studying where you study or\nwork very hard for some amount of time",
"start": 2416.94,
"duration": 4.187
},
{
"text": "and then you take a short break.",
"start": 2421.127,
"duration": 1.333
},
{
"text": "And then you work hard for\nsome short amount of time",
"start": 2422.46,
"duration": 2.166
},
{
"text": "and then you take a short break.",
"start": 2424.626,
"duration": 1.605
},
{
"text": "And so what you're going to be\ncreating in your next project",
"start": 2426.231,
"duration": 2.499
},
{
"text": "is actually a timer that\nallows you to do that.",
"start": 2428.73,
"duration": 2.46
},
{
"text": "It will automatically track for\nyou however long you want to work.",
"start": 2431.19,
"duration": 4.79
},
{
"text": "And it will also allow\nyou to set some time",
"start": 2435.98,
"duration": 2.227
},
{
"text": "that you want to take a break\nin between those working blocks.",
"start": 2438.207,
"duration": 2.583
},
{
"text": "And it will do that.",
"start": 2440.79,
"duration": 0.833
},
{
"text": "So when you start the timer it will\ncount down until you're done working.",
"start": 2441.623,
"duration": 3.787
},
{
"text": "It will let you know,\nhey time for a break.",
"start": 2445.41,
"duration": 2.28
},
{
"text": "Then it will switch over\nto that break timer,",
"start": 2447.69,
"duration": 1.98
},
{
"text": "run down until that ends up and\nsays, oh now it's time to work,",
"start": 2449.67,
"duration": 3.12
},
{
"text": "and it will cycle through that.",
"start": 2452.79,
"duration": 1.82
},
{
"text": "And so in order to do\nthat, you might need",
"start": 2454.61,
"duration": 1.75
},
{
"text": "to know how to work things like timers.",
"start": 2456.36,
"duration": 2.85
},
{
"text": "And so these methods may be a chance\nfor you to set up those timers.",
"start": 2459.21,
"duration": 5.41
},
{
"text": "And so let's go ahead and\ndo an example doing that.",
"start": 2464.62,
"duration": 3.08
},
{
"text": "So first let's get rid\nof all of this stuff.",
"start": 2467.7,
"duration": 6.22
},
{
"text": "So in this example we\nno longer need TODOs.",
"start": 2473.92,
"duration": 4.27
},
{
"text": "And in our render lets\nactually just have some count.",
"start": 2478.19,
"duration": 4.88
},
{
"text": "Those have a View.",
"start": 2483.07,
"duration": 0.75
},
{
"text": "And inside here let's have some text.",
"start": 2488.62,
"duration": 1.96
},
{
"text": "And that text is just\ngoing to show some count.",
"start": 2496.27,
"duration": 2.1
},
{
"text": "And let's initialize that count to 0.",
"start": 2505.04,
"duration": 1.67
},
{
"text": "So, as soon as I get rid of all this, we\nhave a very simple app and all it does",
"start": 2515.55,
"duration": 5.31
},
{
"text": "is show a count of 0.",
"start": 2520.86,
"duration": 1.07
},
{
"text": "You see it up in this\nleft hand corner here.",
"start": 2521.93,
"duration": 2.49
},
{
"text": "And let's go ahead and\nactually center this.",
"start": 2524.42,
"duration": 1.88
},
{
"text": "So let's do styles, and let's\ncreate a new style sheet.",
"start": 2526.3,
"duration": 6.74
},
{
"text": "Let's call this app container and\nwhatever we want to do in here.",
"start": 2537.42,
"duration": 3.91
},
{
"text": "So let's have it grow as much as we can.",
"start": 2541.33,
"duration": 2.719
},
{
"text": "Let's have it center its items.",
"start": 2544.049,
"duration": 1.291
},
{
"text": "And let's have it align its items\nthe other direction as well.",
"start": 2549.69,
"duration": 4.95
},
{
"text": "And down here let's actually pass\nthis in as styles.appcontainer.",
"start": 2562.24,
"duration": 4.76
},
{
"text": "So now we see this\nnumber 0 is very small.",
"start": 2573.0,
"duration": 1.97
},
{
"text": "Let's go ahead and make\nit a little bit bigger.",
"start": 2574.97,
"duration": 2.73
},
{
"text": "And so let's have count and\nlet's give it a big font",
"start": 2577.7,
"duration": 4.65
},
{
"text": "size of like 48 or something.",
"start": 2582.35,
"duration": 3.669
},
{
"text": "So now-- style--",
"start": 2592.87,
"duration": 4.94
},
{
"text": "we have a big number\nand all it does is 0.",
"start": 2597.81,
"duration": 2.16
},
{
"text": "And so how are we going\nto get it to count?",
"start": 2599.97,
"duration": 2.43
},
{
"text": "Well presumably we should\nbe setting our state",
"start": 2602.4,
"duration": 2.25
},
{
"text": "and just have that state increase.",
"start": 2604.65,
"duration": 4.05
},
{
"text": "And so if we want to repeat something\nwhat might we use to achieve that?",
"start": 2608.7,
"duration": 5.69
},
{
"text": "So do something at some given interval.",
"start": 2618.21,
"duration": 3.81
},
{
"text": "We can actually use that set interval.",
"start": 2622.02,
"duration": 2.83
},
{
"text": "And so let's first implement this count.",
"start": 2624.85,
"duration": 2.2
},
{
"text": "So let's have this\nthing called increment.",
"start": 2627.05,
"duration": 2.1
},
{
"text": "Is this too small?",
"start": 2629.15,
"duration": 3.44
},
{
"text": "Let's have this thing called ink.",
"start": 2632.59,
"duration": 2.05
},
{
"text": "And what that does is it does\nthis.setstate, takes a previous state",
"start": 2634.64,
"duration": 8.81
},
{
"text": "and returns the count to be 1\ngreater than the previous state.",
"start": 2643.45,
"duration": 4.74
},
{
"text": "And so now we've implemented this\nthing called increment where we",
"start": 2653.45,
"duration": 4.77
},
{
"text": "take the states count and increment it.",
"start": 2658.22,
"duration": 3.25
},
{
"text": "And so how might we get this increment\ncall to happen every once in a while?",
"start": 2661.47,
"duration": 6.497
},
{
"text": "Well presumably we\nshould use a thing called",
"start": 2667.967,
"duration": 1.833
},
{
"text": "set interval, which we'll call\na function every n milliseconds.",
"start": 2669.8,
"duration": 4.35
},
{
"text": "But how are we going\nto get that to happen?",
"start": 2674.15,
"duration": 3.219
},
{
"text": "Well we should do this after\nthe component finishes mounting.",
"start": 2677.369,
"duration": 2.541
},
{
"text": "We should set up some sort of timer.",
"start": 2679.91,
"duration": 2.33
},
{
"text": "And so how do we know or\nhow do we get a function",
"start": 2682.24,
"duration": 2.26
},
{
"text": "to execute after\ncomponents finish mounting?",
"start": 2684.5,
"duration": 4.73
},
{
"text": "That's actually where this\nlifecycle method comes in.",
"start": 2689.23,
"duration": 2.519
},
{
"text": "And so there's this\nlifecycle method called",
"start": 2691.749,
"duration": 1.791
},
{
"text": "componentDidMount which\nautomatically gets",
"start": 2693.54,
"duration": 2.54
},
{
"text": "run for after the component mounts.",
"start": 2696.08,
"duration": 2.63
},
{
"text": "And so we can actually set\nup our timer tap in there.",
"start": 2698.71,
"duration": 3.38
},
{
"text": "And so we can do componentDidMount\nand inside of it we can do setInterval",
"start": 2702.09,
"duration": 8.42
},
{
"text": "and that's called\nthis.Increment every second.",
"start": 2710.51,
"duration": 5.58
},
{
"text": "And so there's going\nto be a small bug here.",
"start": 2716.09,
"duration": 4.56
},
{
"text": "Does anybody know what the bug is?",
"start": 2720.65,
"duration": 3.25
},
{
"text": "So every 1,000 milliseconds this\nthing called this.Increment is getting",
"start": 2727.08,
"duration": 3.81
},
{
"text": "called.",
"start": 2730.89,
"duration": 1.0
},
{
"text": "And this.Increment is\ninvoking this.Setstate.",
"start": 2731.89,
"duration": 3.42
},
{
"text": "Does anybody see how\nthat might be a problem?",
"start": 2737.98,
"duration": 3.206
},
{
"text": "I'll give you a hint.",
"start": 2747.15,
"duration": 0.99
},
{
"text": "It has something to do with this.",
"start": 2748.14,
"duration": 4.52
},
{
"text": "And so when this gets executed this\nmight not mean what this is here.",
"start": 2752.66,
"duration": 4.83
},
{
"text": "And so this is a common bug in React.",
"start": 2757.49,
"duration": 1.94
},
{
"text": "Oftentimes, when you say\nthis here, what it means",
"start": 2759.43,
"duration": 4.59
},
{
"text": "lexically is not\nnecessarily what it means",
"start": 2764.02,
"duration": 2.13
},
{
"text": "when it actually eventually gets run.",
"start": 2766.15,
"duration": 2.16
},
{
"text": "And so how did we go about fixing\nthis bug in previous lectures?",
"start": 2768.31,
"duration": 7.06
},
{
"text": "We have to somehow get this to be\nbound to what we want it to be.",
"start": 2775.37,
"duration": 3.81
},
{
"text": "And in case we want it\nto be bound lexically.",
"start": 2779.18,
"duration": 4.27
},
{
"text": "So a few different ways to do that.",
"start": 2783.45,
"duration": 1.93
},
{
"text": "One way was creating a new function\nhere in line that does this.",
"start": 2785.38,
"duration": 4.22
},
{
"text": "And I'm actually not sure that\nthat works in this example",
"start": 2793.0,
"duration": 5.39
},
{
"text": "because this isn't necessarily set here.",
"start": 2798.39,
"duration": 3.18
},
{
"text": "The way we've generally handled\nthis is by actually binding it",
"start": 2801.57,
"duration": 7.12
},
{
"text": "at creation time.",
"start": 2808.69,
"duration": 2.54
},
{
"text": "And so there's a\nshorthand whereby we can",
"start": 2811.23,
"duration": 10.79
},
{
"text": "say when we create this\nincrement function automatically",
"start": 2822.02,
"duration": 4.5
},
{
"text": "bind it to this class.",
"start": 2826.52,
"duration": 2.01
},
{
"text": "And so this is actually a new\naddition to the ECMAScript standard",
"start": 2828.53,
"duration": 6.33
},
{
"text": "where this is called\nclass properties whereby",
"start": 2834.86,
"duration": 2.34
},
{
"text": "inline as we're declaring\nthis class we can also",
"start": 2837.2,
"duration": 2.97
},
{
"text": "create properties that should\nbe added during the constructor.",
"start": 2840.17,
"duration": 3.7
},
{
"text": "And so this is syntactically\nthe same as doing this.",
"start": 2843.87,
"duration": 6.41
},
{
"text": "Having the increment function\ndefined as we did before.",
"start": 2850.28,
"duration": 9.79
},
{
"text": "And in the constructor\nwhen this is created",
"start": 2860.07,
"duration": 2.02
},
{
"text": "doing this.Increment equals\nthis.Increment.bind whatever",
"start": 2862.09,
"duration": 9.4
},
{
"text": "the this context we want to be.",
"start": 2871.49,
"duration": 2.29
},
{
"text": "And in this case it's this.",
"start": 2873.78,
"duration": 3.06
},
{
"text": "Or in other words, it's\nthe same as just doing",
"start": 2876.84,
"duration": 2.16
},
{
"text": "this.Increment is equal to the anonymous\nfunction that we defined down there.",
"start": 2879.0,
"duration": 4.01
},
{
"text": "Whatever.",
"start": 2887.03,
"duration": 2.58
},
{
"text": "And so that's just, rather than having\nto write everything in the constructor,",
"start": 2889.61,
"duration": 5.56
},
{
"text": "we can just use this\nshorthand down here which",
"start": 2895.17,
"duration": 7.68
},
{
"text": "is just generally the preferred\nway because it's easier to read.",
"start": 2902.85,
"duration": 6.164
},
{
"text": "And now we've gone ahead and\ncreated this timer that runs.",
"start": 2909.014,
"duration": 2.416
},
{
"text": "And so you can see that\nthe numbers are going up.",
"start": 2911.43,
"duration": 3.277
},
{
"text": "And the reason that this is happening\nis because we created this increment",
"start": 2914.707,
"duration": 3.083
},
{
"text": "function.",
"start": 2917.79,
"duration": 0.75
},
{
"text": "We correctly bound it to the\nthis that we wanted to bind it to",
"start": 2918.54,
"duration": 3.177
},
{
"text": "and then we said, hey,\ncomponent when you're",
"start": 2921.717,
"duration": 1.833
},
{
"text": "done mounting set up this timer, set up\non an interval of 1,000 milliseconds.",
"start": 2923.55,
"duration": 5.32
},
{
"text": "So every second call\nthis increment function.",
"start": 2928.87,
"duration": 2.522
},
{
"text": "And what does that\nincrement function do?",
"start": 2931.392,
"duration": 1.708
},
{
"text": "Well it updates the state to be\nthe previous states count plus 1",
"start": 2933.1,
"duration": 3.5
},
{
"text": "and then down in the render\nwe render this.state.count.",
"start": 2936.6,
"duration": 3.3
},
{
"text": "And so you see every second the\nstate gets updated to a new number,",
"start": 2939.9,
"duration": 4.17
},
{
"text": "and the new number is shown there.",
"start": 2944.07,
"duration": 2.46
},
{
"text": "And so we never had to manually say\nhey, run this code when you mount.",
"start": 2946.53,
"duration": 9.15
},
{
"text": "We just created this method called\ncomponent.DidMount and React handles",
"start": 2955.68,
"duration": 5.28
},
{
"text": "automatically invoking that for\nyou after the component mounted.",
"start": 2960.96,
"duration": 2.82
},
{
"text": "And it's the same as the constructor.",
"start": 2967.59,
"duration": 2.08
},
{
"text": "We never had to manually\ninvoke the constructor.",
"start": 2969.67,
"duration": 2.08
},
{
"text": "It just gets called automatically when\na class instance is getting created?",
"start": 2971.75,
"duration": 3.65
},
{
"text": "Any questions on the mount cycle or\nthe mount processor I should say?",
"start": 2978.22,
"duration": 5.25
},
{
"text": "Great so now let's talk\nabout the update cycle.",
"start": 2991.01,
"duration": 4.23
},
{
"text": "And so, just like in\nthe mounting process,",
"start": 2995.24,
"duration": 2.17
},
{
"text": "there is a bunch of lifecycle hooks\nthat got called for you automatically.",
"start": 2997.41,
"duration": 3.35
},
{
"text": "There are also a bunch\nof lifecycle hooks",
"start": 3000.76,
"duration": 1.708
},
{
"text": "that get called automatically every\nsingle time we want to re-render.",
"start": 3002.468,
"duration": 4.762
},
{
"text": "And so the first thing\nthat happens is component",
"start": 3007.23,
"duration": 2.38
},
{
"text": "will receive props which\ntakes the next props.",
"start": 3009.61,
"duration": 3.54
},
{
"text": "And so say you had\nsomething in your state",
"start": 3013.15,
"duration": 2.1
},
{
"text": "that really depended on\nwhat the props were set to,",
"start": 3015.25,
"duration": 3.744
},
{
"text": "you can actually use this function\nto update any of those state fields",
"start": 3018.994,
"duration": 2.916
},
{
"text": "that rely on the props.",
"start": 3021.91,
"duration": 1.51
},
{
"text": "And you do that by\ncalling this .setstate.",
"start": 3023.42,
"duration": 2.9
},
{
"text": "Next is this thing called\nshouldComponentUpdate,",
"start": 3026.32,
"duration": 3.15
},
{
"text": "which takes the next\nprops and the next date,",
"start": 3029.47,
"duration": 2.94
},
{
"text": "and here you can compare change\nvalues and decide whether or not",
"start": 3032.41,
"duration": 3.54
},
{
"text": "you want that component to render.",
"start": 3035.95,
"duration": 1.47
},
{
"text": "And you can actually stop\nthe update cycle here.",
"start": 3037.42,
"duration": 4.14
},
{
"text": "And so this is a good optimization.",
"start": 3044.26,
"duration": 2.1
},
{
"text": "So say you have a very\ncomplicated component",
"start": 3046.36,
"duration": 2.14
},
{
"text": "that takes a really long time\nto render you don't necessarily",
"start": 3048.5,
"duration": 3.54
},
{
"text": "want it to render every\nsingle time you get a new prop",
"start": 3052.04,
"duration": 3.18
},
{
"text": "because it might be that the\nnew prop doesn't actually",
"start": 3055.22,
"duration": 2.25
},
{
"text": "change anything that's shown.",
"start": 3057.47,
"duration": 2.04
},
{
"text": "And so you could use this\nmethod to stop it early.",
"start": 3059.51,
"duration": 4.02
},
{
"text": "But that adds a lot of\ncomplexity to your app",
"start": 3063.53,
"duration": 1.89
},
{
"text": "and there's almost always\na premature optimization.",
"start": 3065.42,
"duration": 3.45
},
{
"text": "The next happens render, we\nknow exactly what happens there.",
"start": 3068.87,
"duration": 4.02
},
{
"text": "And last we have this thing\ncalled ComponentDidUpdate,",
"start": 3072.89,
"duration": 3.06
},
{
"text": "whereby you can do anything\nthat isn't needed for the UI,",
"start": 3075.95,
"duration": 3.06
},
{
"text": "like network requests,\nwhich is basically",
"start": 3079.01,
"duration": 2.25
},
{
"text": "the analog for ComponentDidMount.",
"start": 3081.26,
"duration": 2.69
},
{
"text": "And so let's see an\nexample for this update.",
"start": 3083.95,
"duration": 3.17
},
{
"text": "So say rather than just\nrendering this text we actually",
"start": 3087.12,
"duration": 8.78
},
{
"text": "pass this count to another function.",
"start": 3095.9,
"duration": 3.16
},
{
"text": "So let's have this thing called a\ncount, which takes as a propped account.",
"start": 3099.06,
"duration": 10.29
},
{
"text": "And then let's create\nthis class called count.",
"start": 3114.47,
"duration": 3.05
},
{
"text": "And then here, let's first\njust render the text.",
"start": 3122.61,
"duration": 3.315
},
{
"text": "And so now we're back to where\nwe started, where we basically",
"start": 3132.16,
"duration": 10.8
},
{
"text": "have some text that gets rendered\nbased on this.PropsAccount,",
"start": 3142.96,
"duration": 4.73
},
{
"text": "and let's style it to be larger.",
"start": 3147.69,
"duration": 2.87
},
{
"text": "And so now we're basically back\nto exactly where we started.",
"start": 3158.201,
"duration": 2.499
},
{
"text": "We have this app which\nautomatically increments",
"start": 3160.7,
"duration": 4.7
},
{
"text": "and then it passes whatever its\nstate count is as the count prop",
"start": 3165.4,
"duration": 3.51
},
{
"text": "to this other class that we call count.",
"start": 3168.91,
"duration": 4.22
},
{
"text": "And then this component\nwe basically just take",
"start": 3173.13,
"duration": 2.35
},
{
"text": "that prop and render that text.",
"start": 3175.48,
"duration": 4.11
},
{
"text": "But say we actually only wanted\nto update on odd numbers.",
"start": 3179.59,
"duration": 5.94
},
{
"text": "So say we want to create a new--",
"start": 3185.53,
"duration": 4.1
},
{
"text": "or say we want to have this\nbe called CountEvennumbers.",
"start": 3189.63,
"duration": 5.39
},
{
"text": "And so, in this example\nhere, how might we say,",
"start": 3203.29,
"duration": 4.79
},
{
"text": "hey don't actually update\nunless your number is even?",
"start": 3208.08,
"duration": 5.97
},
{
"text": "Right now every single time it\nreceives a new prop it's updating.",
"start": 3214.05,
"duration": 5.02
},
{
"text": "But say we only wanted to count even\nnumbers, what's some strategy that we",
"start": 3219.07,
"duration": 4.07
},
{
"text": "may use in order to skip the\nrendering for odd numbers",
"start": 3223.14,
"duration": 3.33
},
{
"text": "and only render on even numbers?",
"start": 3226.47,
"duration": 1.59
},
{
"text": "AUDIENCE: You could use\n[INAUDIBLE] before an update.",
"start": 3234.78,
"duration": 3.85
},
{
"text": "SPEAKER 1: Yeah, so we have this\nthing called shouldComponentUpdate,",
"start": 3238.63,
"duration": 3.38
},
{
"text": "which takes the next props.",
"start": 3242.01,
"duration": 1.17
},
{
"text": "And so we have the ability\nto look at the next props",
"start": 3243.18,
"duration": 2.19
},
{
"text": "and decide whether or\nnot we want to update,",
"start": 3245.37,
"duration": 2.77
},
{
"text": "and if we return false from this\nfunction, the update cycle is over.",
"start": 3248.14,
"duration": 3.74
},
{
"text": "It won't render.",
"start": 3251.88,
"duration": 2.2
},
{
"text": "And so if in this function we wanted\nto check if that count were odd",
"start": 3254.08,
"duration": 6.26
},
{
"text": "we can abort early.",
"start": 3260.34,
"duration": 2.05
},
{
"text": "And so let's actually do that.",
"start": 3262.39,
"duration": 1.61
},
{
"text": "So let's have this method\ncalled shouldComponentUpdate",
"start": 3264.0,
"duration": 5.784
},
{
"text": "and first let's just return false.",
"start": 3269.784,
"duration": 1.416
},
{
"text": "Now what's going to happen here?",
"start": 3273.857,
"duration": 1.333
},
{
"text": "Nothing.",
"start": 3277.91,
"duration": 0.88
},
{
"text": "We can see that it's receiving stuff.",
"start": 3278.79,
"duration": 1.74
},
{
"text": "So see down here in the logs\nwe're receiving this thing called",
"start": 3288.46,
"duration": 4.94
},
{
"text": "updating every second.",
"start": 3293.4,
"duration": 2.83
},
{
"text": "But the UI is just stuck\nat 0, it never updates",
"start": 3296.23,
"duration": 2.592
},
{
"text": "and that's because we're saying\nhey, should the component update?",
"start": 3298.822,
"duration": 2.708
},
{
"text": "No we shouldn't.",
"start": 3301.53,
"duration": 1.59
},
{
"text": "And so React is saying,\nOK, then we're not",
"start": 3303.12,
"duration": 1.98
},
{
"text": "going to call this render method\nand nothing changes over here.",
"start": 3305.1,
"duration": 3.92
},
{
"text": "And so how may we change this is such\nthat it only counts the even numbers?",
"start": 3309.02,
"duration": 5.65
},
{
"text": "Well we can say return, check to see if\nthe next Props.count is divisible by 2.",
"start": 3319.74,
"duration": 16.17
},
{
"text": "And, if it returns true, that\nmeans we're an odd number.",
"start": 3335.91,
"duration": 11.81
},
{
"text": "But what we want is whether\nwe're an even number.",
"start": 3347.72,
"duration": 2.89
},
{
"text": "And so we can actually just say,\noh, return the inverse of this.",
"start": 3350.61,
"duration": 3.104
},
{
"text": "And now it's only going to\ncount those even numbers.",
"start": 3353.714,
"duration": 2.166
},
{
"text": "Does that make sense?",
"start": 3361.456,
"duration": 0.874
},
{
"text": "And so say we wanted to do\nsomething like send a request",
"start": 3366.4,
"duration": 4.075
},
{
"text": "or server every single\ntime this UI updated,",
"start": 3370.475,
"duration": 5.675
},
{
"text": "we wouldn't really want to\ndo that in the render cycle,",
"start": 3376.15,
"duration": 2.31
},
{
"text": "we wouldn't really want to do\nit in shouldComponentUpdate.",
"start": 3378.46,
"duration": 4.6
},
{
"text": "We can actually do that\nin ComponentDidUpdate.",
"start": 3383.06,
"duration": 2.198
},
{
"text": "And so we can actually do for\nnow let's just console.log.",
"start": 3388.32,
"duration": 3.18
},
{
"text": "We can say, hey, we updated it\nand we created a new number.",
"start": 3397.13,
"duration": 4.63
},
{
"text": "And as you see, it's only getting\ncalled for those even numbers.",
"start": 3401.76,
"duration": 4.4
},
{
"text": "Because first shouldComponentUpdate\ngets called and then",
"start": 3406.16,
"duration": 3.81
},
{
"text": "it renders and then\nComponentDidUpdate gets called.",
"start": 3409.97,
"duration": 3.05
},
{
"text": "And, since we exit early\non all odd numbers,",
"start": 3413.02,
"duration": 3.1
},
{
"text": "only the even numbers will reach the\nrender cycle and ComponentDidUpdate.",
"start": 3416.12,
"duration": 4.29
},
{
"text": "And so what you see logged\nare only those even numbers.",
"start": 3420.41,
"duration": 2.49
},
{
"text": "So does this concept of updating\nand methods that automatically",
"start": 3430.21,
"duration": 5.61
},
{
"text": "get invoked makes sense to everyone?",
"start": 3435.82,
"duration": 3.324
},
{
"text": "AUDIENCE: Could you only\ndo this kind of stuff",
"start": 3439.144,
"duration": 2.39
},
{
"text": "with [INAUDIBLE] and not\nthe purely functional ones?",
"start": 3441.534,
"duration": 2.56
},
{
"text": "SPEAKER 1: Yeah.",
"start": 3444.094,
"duration": 0.666
},
{
"text": "So the question was, do these\nmethods exist on the functional ones?",
"start": 3444.76,
"duration": 3.93
},
{
"text": "And they don't because, say\nthis functional components",
"start": 3448.69,
"duration": 4.2
},
{
"text": "are literally just functions.",
"start": 3452.89,
"duration": 2.37
},
{
"text": "They take props and they return a node.",
"start": 3455.26,
"duration": 2.07
},
{
"text": "And so since they're functions,\nall they do are get invoked.",
"start": 3457.33,
"duration": 3.24
},
{
"text": "You pass them props and\nthen you get a node back.",
"start": 3460.57,
"duration": 2.452
},
{
"text": "And in order to have\nthese methods you actually",
"start": 3463.022,
"duration": 1.958
},
{
"text": "have to have this\nconcept of an instance.",
"start": 3464.98,
"duration": 5.67
},
{
"text": "And so React components have\ninstances, and these instances",
"start": 3470.65,
"duration": 3.15
},
{
"text": "are tracked throughout their lifecycle.",
"start": 3473.8,
"duration": 1.92
},
{
"text": "And since these are class\ninstances React well",
"start": 3475.72,
"duration": 4.59
},
{
"text": "go ahead and invoke\nthose methods for you.",
"start": 3480.31,
"duration": 3.54
},
{
"text": "And so the stateless\nfunctional components",
"start": 3483.85,
"duration": 2.254
},
{
"text": "are just functions that\nget invoked and do not",
"start": 3486.104,
"duration": 1.916
},
{
"text": "have these class methods, whereas\nthe React components not only have",
"start": 3488.02,
"duration": 3.96
},
{
"text": "these methods but the methods also\nget invoked automatically for you.",
"start": 3491.98,
"duration": 3.14
},
{
"text": "But yeah great question.",
"start": 3495.12,
"duration": 1.0
},
{
"text": "So that's the update cycle.",
"start": 3500.36,
"duration": 2.43
},
{
"text": "And then lastly we have what's\ncalled the unmount cycle.",
"start": 3502.79,
"duration": 3.566
},
{
"text": "There's only one thing that\nhappens in the unmount cycle.",
"start": 3506.356,
"duration": 2.374
},
{
"text": "You have componentWillUnmount which\ngives you a chance to clean up.",
"start": 3508.73,
"duration": 4.42
},
{
"text": "What do I mean by clean up?",
"start": 3513.15,
"duration": 1.13
},
{
"text": "Well, you can remove any event listeners\nif you had them in React, mostly Web.",
"start": 3514.28,
"duration": 5.91
},
{
"text": "You can invalidate any network\nrequests that you have out.",
"start": 3520.19,
"duration": 2.67
},
{
"text": "Or lastly you should clear\nany timeouts or intervals.",
"start": 3522.86,
"duration": 3.0
},
{
"text": "And so there's actually some bugs that\nyou can create if you're not careful.",
"start": 3525.86,
"duration": 6.1
},
{
"text": "So let's actually revert\nthis back to being",
"start": 3531.96,
"duration": 8.86
},
{
"text": "just an app that shows that count.",
"start": 3540.82,
"duration": 6.43
},
{
"text": "So now we have again that\nnumber being incremented.",
"start": 3555.81,
"duration": 3.61
},
{
"text": "And this class called app keeps track\nof its own number and is updating.",
"start": 3567.75,
"duration": 6.52
},
{
"text": "But say, let's actually\ncall this counter",
"start": 3574.27,
"duration": 5.03
},
{
"text": "and create this thing called app.",
"start": 3579.3,
"duration": 2.1
},
{
"text": "And in this, let's actually\njust show the component.",
"start": 3590.59,
"duration": 2.752
},
{
"text": "So now we have basically\nthe same exact thing.",
"start": 3615.49,
"duration": 2.03
},
{
"text": "So we have this thing\ncalled class app which",
"start": 3617.52,
"duration": 2.87
},
{
"text": "just returns an instance of counter.",
"start": 3620.39,
"duration": 2.54
},
{
"text": "And counter is what we've\nbeen working on thus far.",
"start": 3622.93,
"duration": 2.44
},
{
"text": "It creates an interval and we'll\nkeep track of that interval",
"start": 3625.37,
"duration": 2.64
},
{
"text": "and keep counting up.",
"start": 3628.01,
"duration": 2.21
},
{
"text": "But say we actually have this button\nthat will toggle whether or not",
"start": 3630.22,
"duration": 3.79
},
{
"text": "this counter is shown.",
"start": 3634.01,
"duration": 1.14
},
{
"text": "And so let's have this\nthing called state",
"start": 3635.15,
"duration": 13.81
},
{
"text": "and let's have this\nflag called show counter",
"start": 3648.96,
"duration": 3.037
},
{
"text": "and let's initialize it to true.",
"start": 3651.997,
"duration": 1.333
},
{
"text": "And then down here we\ncan do something like,",
"start": 3657.27,
"duration": 4.8
},
{
"text": "if you should show the\ncounter then return this.",
"start": 3662.07,
"duration": 9.25
},
{
"text": "Else let's just return an empty view.",
"start": 3676.96,
"duration": 2.356
},
{
"text": "And so now this is basically\nthe exact same thing",
"start": 3687.75,
"duration": 2.76
},
{
"text": "because we have no way to change whether\nor not we want to show the counter.",
"start": 3690.51,
"duration": 4.65
},
{
"text": "But say we did, so let's\ncreate toggleCounter.",
"start": 3695.16,
"duration": 2.61
},
{
"text": "So show counter.",
"start": 3708.04,
"duration": 2.17
},
{
"text": "It should be the opposite of what\nthe previous state show counter was.",
"start": 3710.21,
"duration": 3.07
},
{
"text": "And let's also have a button\nthat will toggle this counter.",
"start": 3716.14,
"duration": 17.34
},
{
"text": "And so now we have a button\nwhere if we click it,",
"start": 3743.37,
"duration": 3.582
},
{
"text": "we can just toggle whether\nor not that counter shows.",
"start": 3746.952,
"duration": 2.208
},
{
"text": "And there's actually\na pretty bad bug here.",
"start": 3761.53,
"duration": 2.726
},
{
"text": "And that is that when we\ntoggled this counter--",
"start": 3767.61,
"duration": 3.512
},
{
"text": "oops, we should return this--",
"start": 3775.59,
"duration": 3.68
},
{
"text": "when you toggle that counter we\nnever actually tell this component,",
"start": 3779.27,
"duration": 6.18
},
{
"text": "hey, stop incrementing.",
"start": 3785.45,
"duration": 3.372
},
{
"text": "It's actually going\nto keep incrementing.",
"start": 3788.822,
"duration": 1.708
},
{
"text": "And so we can show that if\nwe have here, if we console",
"start": 3790.53,
"duration": 2.94
},
{
"text": "that log we see that it's\nincrementing, and if we toggle it,",
"start": 3793.47,
"duration": 10.66
},
{
"text": "it's still logging.",
"start": 3804.13,
"duration": 1.47
},
{
"text": "So counters now gone.",
"start": 3805.6,
"duration": 2.29
},
{
"text": "So there's no counter here, it's\ngone but it keeps saying increment.",
"start": 3807.89,
"duration": 6.32
},
{
"text": "And, if we show it again, now look\nat how fast it's incrementing.",
"start": 3814.21,
"duration": 10.15
},
{
"text": "It's two every second because\nthe first counter created",
"start": 3824.36,
"duration": 5.17
},
{
"text": "an incrementing function every 1,000\nmilliseconds and the second time",
"start": 3829.53,
"duration": 4.2
},
{
"text": "we created one it also did.",
"start": 3833.73,
"duration": 2.94
},
{
"text": "And so what if we did this again.",
"start": 3836.67,
"duration": 1.59
},
{
"text": "Toggle and then toggle again.",
"start": 3838.26,
"duration": 3.42
},
{
"text": "Now it's going up three every second.",
"start": 3841.68,
"duration": 1.9
},
{
"text": "And if we did this a bunch of times,\nyou see it's going pretty crazy now.",
"start": 3843.58,
"duration": 4.67
},
{
"text": "It's like five every second.",
"start": 3848.25,
"duration": 2.072
},
{
"text": "And so that's not good.",
"start": 3850.322,
"duration": 0.958
},
{
"text": "That's definitely not good at all.",
"start": 3851.28,
"duration": 1.99
},
{
"text": "Say you had a super complex app\nand hundreds of timers getting set",
"start": 3853.27,
"duration": 4.55
},
{
"text": "and you kept toggling them.",
"start": 3857.82,
"duration": 1.53
},
{
"text": "Eventually you're going to have a\nbig problem where a bunch of things",
"start": 3859.35,
"duration": 3.03
},
{
"text": "are getting called and nothing\nshould be getting called.",
"start": 3862.38,
"duration": 2.91
},
{
"text": "And so that's like a memory leak and\nit could cause your app to crash.",
"start": 3865.29,
"duration": 4.35
},
{
"text": "And so how might we\ngo about solving this?",
"start": 3869.64,
"duration": 3.61
},
{
"text": "So, as we alluded to, there's\nthis thing called an unmount cycle",
"start": 3873.25,
"duration": 3.11
},
{
"text": "where we have a chance to clean up.",
"start": 3876.36,
"duration": 2.01
},
{
"text": "We can get rid of any\ntimers that we've created.",
"start": 3878.37,
"duration": 5.16
},
{
"text": "And so you can actually do that here.",
"start": 3883.53,
"duration": 3.0
},
{
"text": "And so, rather than just\nsetting the interval,",
"start": 3886.53,
"duration": 2.22
},
{
"text": "we should actually track that\nfunction that we created.",
"start": 3888.75,
"duration": 3.06
},
{
"text": "And so you can do something like\nthis.Interval equals setInterval.",
"start": 3891.81,
"duration": 6.18
},
{
"text": "And so setInterval actually returns like\nan ID of the interval that you created.",
"start": 3897.99,
"duration": 5.63
},
{
"text": "And so now we're tracking exactly\nthe interval that we created.",
"start": 3903.62,
"duration": 4.94
},
{
"text": "And we can go ahead and right\nbefore this component dies,",
"start": 3908.56,
"duration": 4.07
},
{
"text": "so component will unmount, we\nshould actually clean that up.",
"start": 3912.63,
"duration": 6.84
},
{
"text": "We can actually do clearInterval\nand we pass in that ID.",
"start": 3919.47,
"duration": 5.445
},
{
"text": "And so now you can see--",
"start": 3929.36,
"duration": 5.07
},
{
"text": "oops, things did not get updated.",
"start": 3934.43,
"duration": 3.375
},
{
"text": "Let's actually copy all\nthis and refresh the page.",
"start": 3937.805,
"duration": 7.617
},
{
"text": "And so when this loads,\nyou'll see that it will still",
"start": 3952.06,
"duration": 4.5
},
{
"text": "log when it's getting shown.",
"start": 3956.56,
"duration": 3.49
},
{
"text": "And so as this number is incrementing we\ncan see it saying, oh I'm incrementing.",
"start": 3960.05,
"duration": 5.42
},
{
"text": "But when we toggle it that\nnumber no longer goes up.",
"start": 3965.47,
"duration": 7.41
},
{
"text": "And then, if we toggle it again,\nit's going to continue incrementing.",
"start": 3972.88,
"duration": 4.33
},
{
"text": "And, if we cancel that,\nthat incrementing function",
"start": 3977.21,
"duration": 3.74
},
{
"text": "is no longer getting called.",
"start": 3980.95,
"duration": 1.76
},
{
"text": "And that's because, over here,\nwhen the component was created,",
"start": 3982.71,
"duration": 5.3
},
{
"text": "so when the component mounts, we set\nthe interval for this button increment",
"start": 3988.01,
"duration": 5.2
},
{
"text": "to happen every 1,000 seconds.",
"start": 3993.21,
"duration": 2.75
},
{
"text": "But then later when we are no\nlonger returning that counter so",
"start": 3995.96,
"duration": 8.72
},
{
"text": "the instance gets unmounted.",
"start": 4004.68,
"duration": 1.5
},
{
"text": "It's no longer part of the React tree.",
"start": 4006.18,
"duration": 1.67
},
{
"text": "Before it gets unmounted, we say\nclear that interval and it clears.",
"start": 4013.89,
"duration": 7.21
},
{
"text": "And then when it remounts\nit creates a new interval.",
"start": 4021.1,
"duration": 3.38
},
{
"text": "And when it gets unmounted again it\ngoes ahead and clears that interval.",
"start": 4024.48,
"duration": 4.47
},
{
"text": "And so now we no longer\nhave any memory leaks.",
"start": 4028.95,
"duration": 1.98
},
{
"text": "So does that whole lifecycle\nprocess make sense to people?",
"start": 4034.76,
"duration": 3.59
},
{
"text": "Do you have any questions\nabout these methods",
"start": 4038.35,
"duration": 2.94
},
{
"text": "or why we might want to use them?",
"start": 4041.29,
"duration": 5.78
},
{
"text": "Cool.",
"start": 4047.07,
"duration": 0.5
},
{
"text": "Let's take a quick five\nminute break and then",
"start": 4047.57,
"duration": 2.36
},
{
"text": "after this, we'll go ahead and\nstart writing some React Native.",
"start": 4049.93,
"duration": 2.88
},
{
"text": "Hello and welcome back.",
"start": 4052.81,
"duration": 1.38
},
{
"text": "So if you are following Snack some\npeople had some questions about style",
"start": 4054.19,
"duration": 5.16
},
{
"text": "and whether or not people\nin industry chose to bundle",
"start": 4059.35,
"duration": 2.79
},
{
"text": "this style with each component.",
"start": 4062.14,
"duration": 2.46
},
{
"text": "And what I tend to\nsee mostly in industry",
"start": 4064.6,
"duration": 2.67
},
{
"text": "is that people do indeed tend to\ninclude the styles with each component",
"start": 4067.27,
"duration": 4.5
},
{
"text": "because part of React's\ncomponent mindset",
"start": 4071.77,
"duration": 2.64
},
{
"text": "is that each component\nshould be a standalone thing",
"start": 4074.41,
"duration": 2.55
},
{
"text": "and it should include with it any event\nhandlers or JavaScript and any style",
"start": 4076.96,
"duration": 5.25
},
{
"text": "as well.",
"start": 4082.21,
"duration": 1.25
},
{
"text": "But there are many compelling\nreasons to actually remove",
"start": 4083.46,
"duration": 3.25
},
{
"text": "the style outside of that component.",
"start": 4086.71,
"duration": 1.95
},
{
"text": "And one big compelling reason would\nbe something like color themes.",
"start": 4088.66,
"duration": 3.51
},
{
"text": "So say you had some color theme where\nyou really liked crimson in your app",
"start": 4092.17,
"duration": 5.91
},
{
"text": "and everywhere you were using crimson.",
"start": 4098.08,
"duration": 2.37
},
{
"text": "And then say suddenly you wanted\nto use something like blue.",
"start": 4100.45,
"duration": 5.4
},
{
"text": "If you had everything\nhard coded to crimson",
"start": 4105.85,
"duration": 2.339
},
{
"text": "it might be a bit of a pain to go\nthrough and find every instance",
"start": 4108.189,
"duration": 3.21
},
{
"text": "of that crimson and change it to blue.",
"start": 4111.399,
"duration": 1.991
},
{
"text": "But say you actually abstracted\nout some value like primary color",
"start": 4113.39,
"duration": 5.299
},
{
"text": "and instead used that in\nall of your components.",
"start": 4118.689,
"duration": 2.669
},
{
"text": "Then if you wanted to change the\nprimary color from crimson to blue",
"start": 4121.358,
"duration": 2.791
},
{
"text": "it would be very easy.",
"start": 4124.149,
"duration": 0.916
},
{
"text": "You would just do it in\none file and be done.",
"start": 4125.065,
"duration": 2.265
},
{
"text": "So there are definitely compelling\nreasons to remove the styles out",
"start": 4127.33,
"duration": 3.87
},
{
"text": "of a particular component.",
"start": 4131.2,
"duration": 2.61
},
{
"text": "And since React Native uses\nJavaScript's objects to style components",
"start": 4133.81,
"duration": 4.169
},
{
"text": "it allows you to do stuff like\ncreate variables and import them in.",
"start": 4137.979,
"duration": 4.541
},
{
"text": "And so are there reasons\nto take the style sheets",
"start": 4142.52,
"duration": 2.75
},
{
"text": "outside of any particular component.",
"start": 4145.27,
"duration": 2.549
},
{
"text": "But generally if you\nhave a choice it's easier",
"start": 4147.819,
"duration": 2.101
},
{
"text": "to just leave it in there\nfor organization sake.",
"start": 4149.92,
"duration": 4.05
},
{
"text": "Cool.",
"start": 4153.97,
"duration": 1.36
},
{
"text": "And so up until now we've been writing\na lot of React Native in this browser",
"start": 4155.33,
"duration": 6.59
},
{
"text": "environment.",
"start": 4161.92,
"duration": 0.78
},
{
"text": "And so let's actually figure out\nand talk about how we actually",
"start": 4162.7,
"duration": 3.6
},
{
"text": "write React Native if you were to\nstart your own personal project",
"start": 4166.3,
"duration": 4.019
},
{
"text": "or assignment for the course.",
"start": 4170.319,
"duration": 3.16
},
{
"text": "So I've been talking about this\ncompany called Expo quite a bit.",
"start": 4173.479,
"duration": 3.21
},
{
"text": "And what they do is they create\na very fast way to build an app.",
"start": 4176.689,
"duration": 3.46
},
{
"text": "They provide a lot of\ntooling around React",
"start": 4180.149,
"duration": 1.75
},
{
"text": "Native and the React native community.",
"start": 4181.899,
"duration": 3.302
},
{
"text": "So there are a suite of tools to\naccelerate the React Native development",
"start": 4185.201,
"duration": 2.999
},
{
"text": "process.",
"start": 4188.2,
"duration": 1.047
},
{
"text": "And so one that we've\nbeen using quite a lot",
"start": 4189.247,
"duration": 1.833
},
{
"text": "is this thing called Snack,\nwhich is this website here.",
"start": 4191.08,
"duration": 3.81
},
{
"text": "We've used it this course,\na lot this lecture and last.",
"start": 4194.89,
"duration": 5.58
},
{
"text": "And what that allows us to do is\nrun React Native in the browser.",
"start": 4200.47,
"duration": 3.06
},
{
"text": "So it automatically\nbundles any libraries",
"start": 4203.53,
"duration": 2.49
},
{
"text": "that we need like React\nNative, React, and then",
"start": 4206.02,
"duration": 3.75
},
{
"text": "it also runs on a phone\nembedded into the browser.",
"start": 4209.77,
"duration": 2.55
},
{
"text": "They also give us a tool\ncalled the XDE which",
"start": 4216.1,
"duration": 3.03
},
{
"text": "is a GUI, graphical user interface,\nto serve share and publish any Expo",
"start": 4219.13,
"duration": 4.8
},
{
"text": "projects that you have.",
"start": 4223.93,
"duration": 2.31
},
{
"text": "They also give us a command\nline interface to do",
"start": 4226.24,
"duration": 2.04
},
{
"text": "the same things, to be a command line.",
"start": 4228.28,
"duration": 3.52
},
{
"text": "They give us the Expo client which,\nif you saw my email from earlier,",
"start": 4231.8,
"duration": 4.25
},
{
"text": "is an iPhone app that you can\ninstall and actually run stuff",
"start": 4236.05,
"duration": 4.29
},
{
"text": "that you write in Snack or\nstuff that you write and manage",
"start": 4240.34,
"duration": 4.29
},
{
"text": "by the XDE or the CLI to actually\nrun it on your phone while developing",
"start": 4244.63,
"duration": 5.31
},
{
"text": "and before you publish.",
"start": 4249.94,
"duration": 2.61
},
{
"text": "And lastly they give us an\nSDK, software development kit,",
"start": 4252.55,
"duration": 3.09
},
{
"text": "which bundles and exposes\ncross-platform libraries and APIs.",
"start": 4255.64,
"duration": 3.93
},
{
"text": "And so included in that are maps, stuff\nfor like icons and images and SVGs",
"start": 4259.57,
"duration": 8.01
},
{
"text": "and maybe animations.",
"start": 4267.58,
"duration": 1.56
},
{
"text": "They also give us handy constants.",
"start": 4269.14,
"duration": 1.56
},
{
"text": "So the Expo that we imported into\nthis app is actually the SDK,",
"start": 4270.7,
"duration": 5.94
},
{
"text": "and it gave us a constant\nlike, we didn't use it here",
"start": 4276.64,
"duration": 4.32
},
{
"text": "but, the height of the status bar.",
"start": 4280.96,
"duration": 3.72
},
{
"text": "And so they give us a\nlot of helpful things",
"start": 4284.68,
"duration": 2.49
},
{
"text": "to really get our developing\nprocess moving forward.",
"start": 4287.17,
"duration": 3.86
},
{
"text": "And so let's take a look at\nthis thing called the XDE.",
"start": 4291.03,
"duration": 3.76
},
{
"text": "So I have it here.",
"start": 4294.79,
"duration": 1.44
},
{
"text": "It's a little bit small but\nbasically what this is is it",
"start": 4300.07,
"duration": 3.9
},
{
"text": "allows us to create and run projects.",
"start": 4303.97,
"duration": 2.38
},
{
"text": "And so I actually already created\nthis project before the class,",
"start": 4306.35,
"duration": 5.04
},
{
"text": "but when you do create your project\nit allows you to choose a template",
"start": 4311.39,
"duration": 4.16
},
{
"text": "and basically create the directory\nand all of its dependencies",
"start": 4315.55,
"duration": 5.01
},
{
"text": "on your computer.",
"start": 4320.56,
"duration": 1.23
},
{
"text": "And so, if you started with the blank\nlike I did and created my new project,",
"start": 4321.79,
"duration": 4.53
},
{
"text": "it gives you a chance to\nsave it wherever you'd like.",
"start": 4326.32,
"duration": 7.2
},
{
"text": "But I already went and did that\nprocess and created my new project.",
"start": 4333.52,
"duration": 2.97
},
{
"text": "And so, if you want to\nfollow along at home,",
"start": 4336.49,
"duration": 2.07
},
{
"text": "you just do create new project,\nblank, save it wherever you like",
"start": 4338.56,
"duration": 3.96
},
{
"text": "and then you end up right here.",
"start": 4342.52,
"duration": 3.76
},
{
"text": "And basically what this is, is\nthis is running a bunch of things",
"start": 4346.28,
"duration": 2.81
},
{
"text": "behind the scenes including React Native\npackager which handles the bundling",
"start": 4349.09,
"duration": 3.81
},
{
"text": "and whatnot of your app and any\nlogs if you want to console log,",
"start": 4352.9,
"duration": 5.37
},
{
"text": "will also appear in this XDE.",
"start": 4358.27,
"duration": 2.31
},
{
"text": "And so what it's doing is it's\nactually looking in that directory",
"start": 4360.58,
"duration": 2.97
},
{
"text": "that it created on your computer.",
"start": 4363.55,
"duration": 2.278
},
{
"text": "And so if you create it and then CD into\nthe correct directory on your computer",
"start": 4374.11,
"duration": 3.78
},
{
"text": "you end up right here.",
"start": 4377.89,
"duration": 1.08
},
{
"text": "And so when you create\na new file you see",
"start": 4381.942,
"duration": 1.708
},
{
"text": "this thing called app.json\nwhich is basically",
"start": 4383.65,
"duration": 5.45
},
{
"text": "a bunch of metadata that's\ncreated about your project and is",
"start": 4389.1,
"duration": 2.5
},
{
"text": "how Expo tracks your app.",
"start": 4391.6,
"duration": 3.21
},
{
"text": "And then you see this\nthing called app.js.",
"start": 4394.81,
"duration": 1.75
},
{
"text": "And that is basically the bare bones\nReact Native app that you start with.",
"start": 4400.48,
"duration": 6.92
},
{
"text": "And when you run it, if you open it\nup on a device, you see it run here.",
"start": 4407.4,
"duration": 8.106
},
{
"text": "And so this says, open up app.js\nto start working on your app.",
"start": 4418.86,
"duration": 3.82
},
{
"text": "And if I were to change the text here\nand save, we can see it re-bundle.",
"start": 4422.68,
"duration": 12.88
},
{
"text": "It's currently building\nthat new JavaScript bundle",
"start": 4435.56,
"duration": 2.13
},
{
"text": "and then you see here, live on the\nphone, that you did update that text.",
"start": 4437.69,
"duration": 5.58
},
{
"text": "And so, if you want to start\nworking on your project earlier",
"start": 4445.89,
"duration": 4.31
},
{
"text": "or work on any personal projects of\nyour own, you're welcome to use Expo.",
"start": 4450.2,
"duration": 3.48
},
{
"text": "I actually encourage you\nto use Expo because they",
"start": 4453.68,
"duration": 2.79
},
{
"text": "take a lot of annoying\nand difficult parts",
"start": 4456.47,
"duration": 2.79
},
{
"text": "about creating projects\nand publishing them",
"start": 4459.26,
"duration": 1.847
},
{
"text": "and do all the hard work for you\nso that all you have to worry about",
"start": 4461.107,
"duration": 2.833
},
{
"text": "is writing the JavaScript here.",
"start": 4463.94,
"duration": 1.291
},
{
"text": "Cool.",
"start": 4470.33,
"duration": 0.99
},
{
"text": "And so we've been doing this thing a\nlot in this lecture and previous ones",
"start": 4471.32,
"duration": 4.089
},
{
"text": "called importing and exporting.",
"start": 4475.409,
"duration": 1.291
},
{
"text": "And we haven't actually\ntalked about what is.",
"start": 4476.7,
"duration": 2.65
},
{
"text": "And so we have talked\na lot about components",
"start": 4479.35,
"duration": 3.1
},
{
"text": "and how we should break up components.",
"start": 4482.45,
"duration": 2.372
},
{
"text": "And it's actually also highly encouraged\nthat you break up the components",
"start": 4484.822,
"duration": 3.968
},
{
"text": "into their own files.",
"start": 4488.79,
"duration": 1.49
},
{
"text": "And so we've seen that components\nare great for simplifying your code",
"start": 4490.28,
"duration": 3.234
},
{
"text": "and we can actually split\nthem into their own files.",
"start": 4493.514,
"duration": 2.166
},
{
"text": "And then what this allows us to do is\nhelp organize the project even more.",
"start": 4495.68,
"duration": 5.19
},
{
"text": "Rather than having everything all\nin one big super long file, which",
"start": 4500.87,
"duration": 3.75
},
{
"text": "might get very unwieldy, we\ncan actually organize things",
"start": 4504.62,
"duration": 2.46
},
{
"text": "into their own separate files\nor even separate folders",
"start": 4507.08,
"duration": 3.57
},
{
"text": "so it's easy to find whatever\ncode you need to update.",
"start": 4510.65,
"duration": 3.89
},
{
"text": "Then what we do is from the\nfile that we create we actually",
"start": 4514.54,
"duration": 3.37
},
{
"text": "export the component that we want.",
"start": 4517.91,
"duration": 2.89
},
{
"text": "And then we can then import it in to\nanother file if we want to use it.",
"start": 4520.8,
"duration": 4.82
},
{
"text": "And there are a couple different\nways to import and export.",
"start": 4527.732,
"duration": 2.458
},
{
"text": "There's this thing\ncalled a default export,",
"start": 4530.19,
"duration": 2.12
},
{
"text": "and there's this thing called\na named import and export.",
"start": 4532.31,
"duration": 2.88
},
{
"text": "And so what I was typing a\nlot earlier is you see me type",
"start": 4535.19,
"duration": 4.57
},
{
"text": "this thing called export\ndefault class app.",
"start": 4539.76,
"duration": 2.62
},
{
"text": "And that's me saying, hey\nfrom this file here I actually",
"start": 4542.38,
"duration": 3.43
},
{
"text": "want to export this app.",
"start": 4545.81,
"duration": 1.56
},
{
"text": "And it should be the default export.",
"start": 4547.37,
"duration": 2.99
},
{
"text": "And so let's take a look\nat what that looks here.",
"start": 4550.36,
"duration": 2.23
},
{
"text": "And so in app.js in a brand\nnew directory I went and--",
"start": 4552.59,
"duration": 3.99
},
{
"text": "the boiler plate code says\nexport this default class app.",
"start": 4559.19,
"duration": 3.0
},
{
"text": "But say I want to in a new file.",
"start": 4562.19,
"duration": 2.05
},
{
"text": "So let me create a new file called\nlet's just call it count.js.",
"start": 4564.24,
"duration": 4.09
},
{
"text": "From here let's first import from\nReact, which is something that we",
"start": 4570.95,
"duration": 6.72
},
{
"text": "have to do in every single file.",
"start": 4577.67,
"duration": 2.28
},
{
"text": "And let's create this\ncomponent called Count.",
"start": 4579.95,
"duration": 2.91
},
{
"text": "So let's do const Count\nequals props and then",
"start": 4582.86,
"duration": 4.2
},
{
"text": "let's return this thing called a view.",
"start": 4587.06,
"duration": 2.79
},
{
"text": "And then have props.count show.",
"start": 4589.85,
"duration": 5.214
},
{
"text": "Actually, let's have this be text.",
"start": 4595.064,
"duration": 1.416
},
{
"text": "So this won't actually work because\nwe're using this component called",
"start": 4603.81,
"duration": 4.53
},
{
"text": "Text here which doesn't exist.",
"start": 4608.34,
"duration": 3.15
},
{
"text": "So Text here, capital T\ncapital Text, is a component",
"start": 4611.49,
"duration": 4.68
},
{
"text": "but this file has no idea what\nText is, what capital Text is.",
"start": 4616.17,
"duration": 5.33
},
{
"text": "It's a component.",
"start": 4621.5,
"duration": 1.64
},
{
"text": "We know it's a component because\nit's in JSX and capitalized",
"start": 4623.14,
"duration": 3.17
},
{
"text": "but nowhere in this file do we\ndeclare this thing called Text.",
"start": 4626.31,
"duration": 3.19
},
{
"text": "And so we actually have to import it\nfrom the library called React Native.",
"start": 4629.5,
"duration": 4.49
},
{
"text": "And so you've seen me\nbefore in the example",
"start": 4645.2,
"duration": 3.33
},
{
"text": "files do this thing called\nimport Text from React Native.",
"start": 4648.53,
"duration": 2.71
},
{
"text": "And what that the actually does is it\ngoes into that React Native API code",
"start": 4651.24,
"duration": 5.0
},
{
"text": "and gives you access to the variable\nthat they're exporting called Text.",
"start": 4656.24,
"duration": 3.79
},
{
"text": "And then when we go\nahead and use it here",
"start": 4660.03,
"duration": 3.95
},
{
"text": "the JavaScript knows that\nthis variable context exists.",
"start": 4663.98,
"duration": 3.25
},
{
"text": "And so how are we going to get this\ncomponent called Count into our app?",
"start": 4667.23,
"duration": 7.43
},
{
"text": "So say I wanted to hear a display\ncount and passed an account of 0.",
"start": 4677.19,
"duration": 8.61
},
{
"text": "So if I save this and\ntry to run it, it's",
"start": 4689.01,
"duration": 2.37
},
{
"text": "going to error because this\nvariable called Count doesn't exist,",
"start": 4691.38,
"duration": 5.29
},
{
"text": "which makes sense right?",
"start": 4696.67,
"duration": 2.06
},
{
"text": "In this app.js file we haven't\ncreated a variable called Count.",
"start": 4698.73,
"duration": 4.59
},
{
"text": "We actually created it in a\nseparate file called count.js.",
"start": 4703.32,
"duration": 5.79
},
{
"text": "And so as I alluded to, you can\nactually export a component from a file",
"start": 4709.11,
"duration": 3.6
},
{
"text": "and import it into a new file.",
"start": 4712.71,
"duration": 2.03
},
{
"text": "And so we can actually, over here,\njust use this term called export.",
"start": 4714.74,
"duration": 4.285
},
{
"text": "And if we go ahead and\nsave this then now we",
"start": 4723.05,
"duration": 2.62
},
{
"text": "can try to import this\nthing called Count from--",
"start": 4725.67,
"duration": 5.115
},
{
"text": "where is it?",
"start": 4734.19,
"duration": 0.636
},
{
"text": "Well, it's in the current\ndirectory, so ./Count.js.",
"start": 4734.826,
"duration": 2.124
},
{
"text": "And so now if we save that we\ncan see that it compiles and we",
"start": 4741.21,
"duration": 5.85
},
{
"text": "see that 0 show up.",
"start": 4747.06,
"duration": 3.39
},
{
"text": "And so let's make it a little bit\nbigger so that's easier to see.",
"start": 4750.45,
"duration": 3.74
},
{
"text": "And so how are we going to do that?",
"start": 4754.19,
"duration": 1.49
},
{
"text": "Let's create this constant called\nstyles and let's have stylesheet.create.",
"start": 4755.68,
"duration": 5.2
},
{
"text": "And let's just have a font size of 72.",
"start": 4765.51,
"duration": 5.24
},
{
"text": "And then here let's just do style is\nthat Styles object that we created.",
"start": 4775.2,
"duration": 9.931
},
{
"text": "And if we save this and run\nit what's going to happen?",
"start": 4785.131,
"duration": 2.249
},
{
"text": "It's going to error.",
"start": 4787.38,
"duration": 1.832
},
{
"text": "And why is it erroring?",
"start": 4789.212,
"duration": 0.958
},
{
"text": "Well it says cannot find variable called\nstylesheet, which makes sense right?",
"start": 4790.17,
"duration": 4.04
},
{
"text": "In this file here nowhere is there\na variable called stylesheet.",
"start": 4794.21,
"duration": 5.027
},
{
"text": "And so we actually also have to\nimport that from React Native.",
"start": 4799.237,
"duration": 2.583
},
{
"text": "And so if we run that and\nsave it, lo and behold,",
"start": 4806.19,
"duration": 2.53
},
{
"text": "it rhymes and the style is applied.",
"start": 4808.72,
"duration": 2.29
},
{
"text": "We see a big number 0 there.",
"start": 4811.01,
"duration": 3.41
},
{
"text": "And so that is called a named export.",
"start": 4814.42,
"duration": 2.13
},
{
"text": "We exported a named\nvariable called Count.",
"start": 4816.55,
"duration": 4.56
},
{
"text": "And then in here in brackets we say\nimport all of the variables named Count",
"start": 4821.11,
"duration": 6.29
},
{
"text": "that we exported from ./Count.js.",
"start": 4827.4,
"duration": 4.48
},
{
"text": "And so that is an example\nof a named export.",
"start": 4831.88,
"duration": 1.89
},
{
"text": "And say we wanted to export another\nnamed variable we can do export const--",
"start": 4833.77,
"duration": 8.048
},
{
"text": "let's just call it num, and\nlet's have it be the number 50.",
"start": 4844.954,
"duration": 6.936
},
{
"text": "And we can, over here, do import\nCount and also num count.js.",
"start": 4851.89,
"duration": 5.91
},
{
"text": "And then rather than passing\nin 0 we can just pass in num.",
"start": 4857.8,
"duration": 4.58
},
{
"text": "And as we see over here\nnow it's the number 50.",
"start": 4862.38,
"duration": 4.13
},
{
"text": "Why is that?",
"start": 4866.51,
"duration": 0.69
},
{
"text": "Well in Count.js we\nexported two variables.",
"start": 4867.2,
"duration": 5.0
},
{
"text": "One we called Count,\nso capital Count here.",
"start": 4872.2,
"duration": 3.75
},
{
"text": "We have a const called Count\nand we're exporting that.",
"start": 4875.95,
"duration": 2.65
},
{
"text": "And so it's a named variable\nthat's getting exported.",
"start": 4878.6,
"duration": 3.09
},
{
"text": "Over here we have a constant called\nnum, and we're exporting that,",
"start": 4881.69,
"duration": 3.42
},
{
"text": "so there's also a named variable\ncalled num that's getting exported.",
"start": 4885.11,
"duration": 3.3
},
{
"text": "Then over here in our\napp file we actually",
"start": 4888.41,
"duration": 2.4
},
{
"text": "import to this thing\ncalled Count and num.",
"start": 4890.81,
"duration": 2.589
},
{
"text": "And so the names do\nmatter because it needs",
"start": 4893.399,
"duration": 1.791
},
{
"text": "to know exactly what we're importing in.",
"start": 4895.19,
"duration": 2.884
},
{
"text": "And then we go ahead and use those\nand they show up as expected.",
"start": 4898.074,
"duration": 2.666
},
{
"text": "And so those are called named\nimports and named exports",
"start": 4903.57,
"duration": 3.32
},
{
"text": "but there's also this thing\ncalled a default export.",
"start": 4906.89,
"duration": 3.0
},
{
"text": "And so you see here we have an\nadditional term called export default",
"start": 4909.89,
"duration": 5.43
},
{
"text": "this value.",
"start": 4915.32,
"duration": 1.51
},
{
"text": "And so in our Count file\nover here let's get rid of--",
"start": 4916.83,
"duration": 3.55
},
{
"text": "or let's not actually\nget rid of anything",
"start": 4920.38,
"duration": 1.75
},
{
"text": "and let's actually do export\ndefault. And then just",
"start": 4922.13,
"duration": 5.42
},
{
"text": "give it a value to export.",
"start": 4927.55,
"duration": 2.94
},
{
"text": "So export default this\nfunction that we're creating",
"start": 4930.49,
"duration": 3.6
},
{
"text": "and if we want to make this more\nobvious what's happening here",
"start": 4934.09,
"duration": 3.03
},
{
"text": "we can actually do\nconst Count equals this.",
"start": 4937.12,
"duration": 7.26
},
{
"text": "And then we can do export\ndefault Count, which",
"start": 4944.38,
"duration": 3.45
},
{
"text": "is saying set the default\nexport of this file to be Count.",
"start": 4947.83,
"duration": 3.7
},
{
"text": "And then how are we going to import it?",
"start": 4953.705,
"duration": 1.625
},
{
"text": "Well, rather than\nimporting these name things",
"start": 4955.33,
"duration": 4.32
},
{
"text": "we just say we want to import\nthis thing from Count.js.",
"start": 4959.65,
"duration": 5.19
},
{
"text": "And since we've dropped\nthose brackets we",
"start": 4964.84,
"duration": 2.52
},
{
"text": "say just import whatever\nis default exporting.",
"start": 4967.36,
"duration": 3.14
},
{
"text": "And we're going to call it here Count.",
"start": 4970.5,
"duration": 2.62
},
{
"text": "And so if you notice it works--",
"start": 4973.12,
"duration": 3.42
},
{
"text": "oops as long as I save all\nthe files but I never--",
"start": 4976.54,
"duration": 9.09
},
{
"text": "let's change this back to 0.",
"start": 4985.63,
"duration": 1.17
},
{
"text": "And so now as you notice it is\nshowing that 0 value as expected.",
"start": 4990.8,
"duration": 3.485
},
{
"text": "But let's actually call\nthis something else.",
"start": 4997.29,
"duration": 2.68
},
{
"text": "So let's call this custom Count.",
"start": 4999.97,
"duration": 2.98
},
{
"text": "So even though over here we're\nexporting a variable called",
"start": 5009.98,
"duration": 4.92
},
{
"text": "Count, since we're are using\nit as a default export,",
"start": 5014.9,
"duration": 4.89
},
{
"text": "we can import the default export in\nthis file and call it whatever you want.",
"start": 5019.79,
"duration": 5.54
},
{
"text": "And so we can call it custom Count over\nhere and it still works as expected.",
"start": 5025.33,
"duration": 5.06
},
{
"text": "And so the difference between named\nand default exports are that named, 1,",
"start": 5030.39,
"duration": 4.67
},
{
"text": "you can export multiple\nof named exports and also",
"start": 5035.06,
"duration": 5.4
},
{
"text": "import to multiple named\nexports from a different file.",
"start": 5040.46,
"duration": 3.96
},
{
"text": "And they do have to be named exactly\nas they are in the other files.",
"start": 5044.42,
"duration": 5.68
},
{
"text": "But when you export\nsomething default you're",
"start": 5050.1,
"duration": 2.15
},
{
"text": "limited to only exporting\none which makes sense.",
"start": 5052.25,
"duration": 2.52
},
{
"text": "If you exported multiple defaults you\nwouldn't know which one to import.",
"start": 5054.77,
"duration": 4.317
},
{
"text": "And then over here, you\ncan call it whatever",
"start": 5059.087,
"duration": 1.833
},
{
"text": "you want because it doesn't matter,\nit's just the default export.",
"start": 5060.92,
"duration": 5.16
},
{
"text": "And so that's how you're\ngoing to go about starting",
"start": 5066.08,
"duration": 2.37
},
{
"text": "to remove components from one long\nfile and move them into separate files.",
"start": 5068.45,
"duration": 7.09
},
{
"text": "And so you can also actually import the\nexport default and also named exports.",
"start": 5075.54,
"duration": 10.37
},
{
"text": "So here we are exporting a named export\nand we're also having a default export.",
"start": 5090.33,
"duration": 7.11
},
{
"text": "And in here we're importing the default\nand we're also importing a named export",
"start": 5097.44,
"duration": 7.9
},
{
"text": "and, as you see, that works as well.",
"start": 5105.34,
"duration": 2.44
},
{
"text": "And so over here you see that we\nare importing React from React which",
"start": 5110.72,
"duration": 5.2
},
{
"text": "is whatever its default export is.",
"start": 5115.92,
"duration": 3.57
},
{
"text": "We could also import one\nof its named exports,",
"start": 5119.49,
"duration": 5.67
},
{
"text": "and rather than extending\na React.component",
"start": 5125.16,
"duration": 2.84
},
{
"text": "we can just extend\ncomponent here because we",
"start": 5128.0,
"duration": 4.3
},
{
"text": "went ahead and imported the named\nexport called component from React.",
"start": 5132.3,
"duration": 4.74
},
{
"text": "And so that will also work as well.",
"start": 5137.04,
"duration": 2.14
},
{
"text": "So any questions on\nimporting and exporting",
"start": 5143.89,
"duration": 2.72
},
{
"text": "and how you would go about\nbreaking up particular components",
"start": 5146.61,
"duration": 3.66
},
{
"text": "into separate files?",
"start": 5150.27,
"duration": 3.04
},
{
"text": "Yeah.",
"start": 5153.31,
"duration": 1.0
},
{
"text": "AUDIENCE: You were able to access\nthe components with React.components.",
"start": 5154.31,
"duration": 6.5
},
{
"text": "Is that because the component is\n[INAUDIBLE] named export and the value",
"start": 5160.81,
"duration": 6.5
},
{
"text": "in the React.components?",
"start": 5167.31,
"duration": 2.0
},
{
"text": "SPEAKER 1: Yes exactly.",
"start": 5169.31,
"duration": 1.0
},
{
"text": "So the question was, I was\nable to access component",
"start": 5170.31,
"duration": 3.83
},
{
"text": "as React.component and\nseparately also as component",
"start": 5174.14,
"duration": 7.86
},
{
"text": "and that's because this thing\ncalled component is actually",
"start": 5182.0,
"duration": 3.69
},
{
"text": "a property on this React.",
"start": 5185.69,
"duration": 4.56
},
{
"text": "And so what React exports is\nboth a default export, which",
"start": 5190.25,
"duration": 4.11
},
{
"text": "is this massive thing where one of\nits object keys is called a component",
"start": 5194.36,
"duration": 7.29
},
{
"text": "and has the value of the component\nand it's also separately exporting",
"start": 5201.65,
"duration": 4.08
},
{
"text": "a named export called component.",
"start": 5205.73,
"duration": 1.86
},
{
"text": "And so we can go ahead and either\nimport the default export and do that",
"start": 5207.59,
"duration": 4.27
},
{
"text": ".component or we can import the\nnamed component and just use that.",
"start": 5211.86,
"duration": 3.61
},
{
"text": "So you're absolutely correct.",
"start": 5215.47,
"duration": 1.92
},
{
"text": "Any other questions on\nimporting and exporting?",
"start": 5221.23,
"duration": 2.99
},
{
"text": "Cool.",
"start": 5227.93,
"duration": 0.5
},
{
"text": "So when we go ahead and\nimport and export components",
"start": 5228.43,
"duration": 4.42
},
{
"text": "they can start to get more and more\ncomplex as we pass down more props.",
"start": 5232.85,
"duration": 5.26
},
{
"text": "And so how might we go about\nkeeping track of all of these props?",
"start": 5238.11,
"duration": 4.22
},
{
"text": "Well React actually has a\nway to help you with that,",
"start": 5242.33,
"duration": 3.09
},
{
"text": "and it's called prop types.",
"start": 5245.42,
"duration": 2.22
},
{
"text": "And so React can actually validate\nthe types of a given components props",
"start": 5247.64,
"duration": 3.9
},
{
"text": "at runtime which is great.",
"start": 5251.54,
"duration": 2.59
},
{
"text": "It's a development tool that\nallows you as a developer",
"start": 5254.13,
"duration": 3.09
},
{
"text": "to ensure that you're\npassing the props that you",
"start": 5257.22,
"duration": 2.0
},
{
"text": "think you're actually passing down.",
"start": 5259.22,
"duration": 1.458
},
{
"text": "And so say you're passing\ndown some prop that's a number",
"start": 5260.678,
"duration": 3.972
},
{
"text": "but you actually want it as a string.",
"start": 5264.65,
"duration": 2.1
},
{
"text": "It's very easy, as your project scales\nup, to kind of get those mixed up",
"start": 5266.75,
"duration": 5.512
},
{
"text": "and maybe you pass down\na string when you meant",
"start": 5272.262,
"duration": 1.958
},
{
"text": "to pass down a number or vise versa.",
"start": 5274.22,
"duration": 3.31
},
{
"text": "And so this thing called PropTypes\nallows you to keep track of that.",
"start": 5277.53,
"duration": 4.31
},
{
"text": "And React will actually do this\nautomatically in development mode.",
"start": 5281.84,
"duration": 4.75
},
{
"text": "And this is also great because\nit helps document your APIs.",
"start": 5286.59,
"duration": 2.78
},
{
"text": "And so I have this very simple\ncomponent over here called Count",
"start": 5289.37,
"duration": 8.19
},
{
"text": "and it takes a single prop called Count.",
"start": 5297.56,
"duration": 2.16
},
{
"text": "But say it also took\nthree other props and say",
"start": 5299.72,
"duration": 2.825
},
{
"text": "it also had 10 other components\nthat also took their own props.",
"start": 5302.545,
"duration": 5.365
},
{
"text": "It might get kind of hard to\nremember that as I scale the project.",
"start": 5307.91,
"duration": 4.11
},
{
"text": "And say you're somebody\nlike Facebook who",
"start": 5312.02,
"duration": 1.8
},
{
"text": "have something like 30,000\ndifferent components in production",
"start": 5313.82,
"duration": 3.69
},
{
"text": "it would be very painful to\nnot have those documented",
"start": 5317.51,
"duration": 2.21
},
{
"text": "and have to go and read the code to\nknow exactly what props you should",
"start": 5319.72,
"duration": 2.98
},
{
"text": "be passing.",
"start": 5322.7,
"duration": 1.45
},
{
"text": "And so by declaring this\nthing called PropTypes",
"start": 5324.15,
"duration": 3.95
},
{
"text": "you actually can help self\ndocument all of these APIs.",
"start": 5328.1,
"duration": 3.59
},
{
"text": "And what's nice is this only\nruns in development mode",
"start": 5331.69,
"duration": 2.23
},
{
"text": "and so you don't have to\nworry about it slowing down",
"start": 5333.92,
"duration": 2.166
},
{
"text": "your production in production mode.",
"start": 5336.086,
"duration": 3.604
},
{
"text": "And so how might we go about doing that?",
"start": 5339.69,
"duration": 2.45
},
{
"text": "There's actually a\npackage called PropTypes.",
"start": 5342.14,
"duration": 2.07
},
{
"text": "It used to be bundled as\npart of React but they've",
"start": 5344.21,
"duration": 2.91
},
{
"text": "since split it into its own\nmodule though it's still",
"start": 5347.12,
"duration": 5.73
},
{
"text": "maintained by Facebook.",
"start": 5352.85,
"duration": 1.62
},
{
"text": "So we can go ahead and do this\nthing called import PropTypes",
"start": 5354.47,
"duration": 4.47
},
{
"text": "from a package called prop-types.",
"start": 5358.94,
"duration": 1.95
},
{
"text": "And so now we have access to\nthis variable called PropTypes",
"start": 5364.97,
"duration": 2.61
},
{
"text": "where importing the default export\nof whatever this library called",
"start": 5367.58,
"duration": 6.36
},
{
"text": "PropTypes is.",
"start": 5373.94,
"duration": 1.63
},
{
"text": "And so now we can go ahead\nand use that in our file.",
"start": 5375.57,
"duration": 2.21
},
{
"text": "And so let's go ahead and do Count.",
"start": 5377.78,
"duration": 4.2
},
{
"text": "And so we created this\nvariable called Count,",
"start": 5381.98,
"duration": 3.25
},
{
"text": "which is a function of a\nstateless functional component.",
"start": 5385.23,
"duration": 3.78
},
{
"text": "And we can actually attached to\nit a property called propTypes.",
"start": 5389.01,
"duration": 6.48
},
{
"text": "Note that it's a lower case p here.",
"start": 5395.49,
"duration": 2.3
},
{
"text": "And I can set it equal to an\nobject and the keys of this object",
"start": 5401.05,
"duration": 3.33
},
{
"text": "will map to whatever\nprops that I expect.",
"start": 5404.38,
"duration": 3.31
},
{
"text": "And so in this case we expect\na single prop called Count.",
"start": 5407.69,
"duration": 3.9
},
{
"text": "And so I can say Count should\nbe of what type, well PropTypes.",
"start": 5411.59,
"duration": 4.8
},
{
"text": "So capital P here is referring to\nthe library that we just imported.",
"start": 5416.39,
"duration": 4.09
},
{
"text": "And we can say we want a\nnumber, and it's required.",
"start": 5420.48,
"duration": 4.24
},
{
"text": "And so now we see this warning.",
"start": 5428.14,
"duration": 5.49
},
{
"text": "We see, hey, there's a\nfailed prop type here.",
"start": 5433.63,
"duration": 4.77
},
{
"text": "The prop count is marked as\nrequired in this component",
"start": 5438.4,
"duration": 3.54
},
{
"text": "called Count but it's values undefined.",
"start": 5441.94,
"duration": 2.49
},
{
"text": "Why is it undefined?",
"start": 5444.43,
"duration": 1.69
},
{
"text": "Well because we're importing\nthis thing called number",
"start": 5446.12,
"duration": 3.71
},
{
"text": "and we're passing this thing\ncalled number over here.",
"start": 5449.83,
"duration": 2.31
},
{
"text": "But we're not actually exporting\nanything called number in this module.",
"start": 5452.14,
"duration": 4.51
},
{
"text": "And say we actually remove\nthat and passed a 0 here.",
"start": 5456.65,
"duration": 7.34
},
{
"text": "Now it'll run as expected.",
"start": 5466.54,
"duration": 1.71
},
{
"text": "There are no warnings thrown.",
"start": 5468.25,
"duration": 2.91
},
{
"text": "And now let's try simulating a mistake\nwhere rather than passing the number 0",
"start": 5471.16,
"duration": 5.22
},
{
"text": "we go ahead and pass the string 0.",
"start": 5476.38,
"duration": 4.32
},
{
"text": "The app will still work because we're\njust displaying whatever we pass.",
"start": 5480.7,
"duration": 4.47
},
{
"text": "But if you notice we\nhave a warning here.",
"start": 5485.17,
"duration": 4.11
},
{
"text": "Warning: Failed prop type.",
"start": 5489.28,
"duration": 1.29
},
{
"text": "Invalid prop count of type\nstring supplied to count.",
"start": 5490.57,
"duration": 3.24
},
{
"text": "We were actually expecting a number.",
"start": 5493.81,
"duration": 1.825
},
{
"text": "And so that's actually\nReact's built-in prop type",
"start": 5495.635,
"duration": 2.675
},
{
"text": "system which is checking against the\ntypes that we're passing down here.",
"start": 5498.31,
"duration": 4.08
},
{
"text": "We say, hey we're expecting\nthis thing as a number",
"start": 5502.39,
"duration": 2.92
},
{
"text": "but since we pass a string it will throw\na warning for us just to let us know,",
"start": 5505.31,
"duration": 3.635
},
{
"text": "oh by the way I don't know\nif you know this or not,",
"start": 5508.945,
"duration": 2.125
},
{
"text": "but you're passing the wrong type down.",
"start": 5511.07,
"duration": 2.25
},
{
"text": "And so we can use this thing\ncalled prop types in order",
"start": 5513.32,
"duration": 2.39
},
{
"text": "to validate the props that were passed.",
"start": 5515.71,
"duration": 5.162
},
{
"text": "And so in stateless\nfunctional components",
"start": 5520.872,
"duration": 1.708
},
{
"text": "we actually just add this as a property.",
"start": 5522.58,
"duration": 3.33
},
{
"text": "But say this were actually\na class component.",
"start": 5525.91,
"duration": 3.81
},
{
"text": "So let's do class Count,\nextends React.component.",
"start": 5529.72,
"duration": 12.96
},
{
"text": "And then we have a render\nwhich will just return this.",
"start": 5542.68,
"duration": 5.357
},
{
"text": "And let's fix some styling\nso it's easier to read.",
"start": 5553.35,
"duration": 2.16
},
{
"text": "So now we have a class component and\nas long as there are no syntax errors--",
"start": 5560.5,
"duration": 7.76
},
{
"text": "There's a syntax error\nsomewhere that I don't see.",
"start": 5571.06,
"duration": 6.16
},
{
"text": "Does anybody see the syntax error?",
"start": 5577.22,
"duration": 1.51
},
{
"text": "Can anybody beat me to it?",
"start": 5578.73,
"duration": 1.693
},
{
"text": "AUDIENCE: Is that last a\nparentheses or is that a bracket?",
"start": 5580.423,
"duration": 3.099
},
{
"text": "SPEAKER 1: This here is a parentheses.",
"start": 5583.522,
"duration": 1.583
},
{
"text": "Oh, yep.",
"start": 5585.105,
"duration": 2.595
},
{
"text": "Nice catch.",
"start": 5587.7,
"duration": 0.745
},
{
"text": "I owe you some candy.",
"start": 5588.445,
"duration": 0.875
},
{
"text": "So now if we go ahead\nand reload this, it",
"start": 5592.08,
"duration": 3.3
},
{
"text": "can't find the called props\nbecause class component",
"start": 5595.38,
"duration": 6.51
},
{
"text": "is stored as this.props.",
"start": 5601.89,
"duration": 2.13
},
{
"text": "And now we can go ahead and\nsee that it is as expected.",
"start": 5604.02,
"duration": 3.789
},
{
"text": "We still have that\nfailed prop type message",
"start": 5607.809,
"duration": 1.791
},
{
"text": "because we're passing a string rather\nthan a number but it's working.",
"start": 5609.6,
"duration": 4.38
},
{
"text": "And so we can go ahead and\nso we create the class here.",
"start": 5613.98,
"duration": 3.7
},
{
"text": "And then we go ahead and do\nCount.propTypes here which works.",
"start": 5617.68,
"duration": 3.84
},
{
"text": "But generally the way that you\nsee the convention is actually",
"start": 5621.52,
"duration": 4.52
},
{
"text": "to use this thing\ncalled a static method.",
"start": 5626.04,
"duration": 3.55
},
{
"text": "And so there's actually a static keyword\nwhere you can do static propTypes",
"start": 5629.59,
"duration": 5.35
},
{
"text": "equals that object.",
"start": 5634.94,
"duration": 1.69
},
{
"text": "So functionally exactly the same, but\nthe convention is to use this thing",
"start": 5642.09,
"duration": 5.27
},
{
"text": "called a static method\nor a static property",
"start": 5647.36,
"duration": 5.88
},
{
"text": "because it's just the way that\nthe new class index works.",
"start": 5653.24,
"duration": 5.53
},
{
"text": "And so it's functionally the same\nas doing count.propTypes down here,",
"start": 5658.77,
"duration": 4.57
},
{
"text": "but the convention is just\nto use the newer syntax.",
"start": 5663.34,
"duration": 2.125
},
{
"text": "So any questions on PropTypes?",
"start": 5668.49,
"duration": 3.38
},
{
"text": "Does everybody see the\nutility of using them?",
"start": 5671.87,
"duration": 2.85
},
{
"text": "They've definitely saved me\nmultiple times on personal projects.",
"start": 5674.72,
"duration": 2.865
},
{
"text": "And so now, if we've passed the\ncorrect props, there are no warnings.",
"start": 5683.83,
"duration": 6.22
},
{
"text": "Great.",
"start": 5690.05,
"duration": 0.5
},
{
"text": "And the last concept I wanted to touch\non is just how the heck do I read docs.",
"start": 5690.55,
"duration": 5.515
},
{
"text": "Because I can't possibly teach\nyou every single component",
"start": 5696.065,
"duration": 2.375
},
{
"text": "that React Native offers.",
"start": 5698.44,
"duration": 1.74
},
{
"text": "But they do offer a\nlot of great components",
"start": 5700.18,
"duration": 2.34
},
{
"text": "that you may want to use in either\nproject for this class or maybe",
"start": 5702.52,
"duration": 3.48
},
{
"text": "a personal project\nthat you're working on.",
"start": 5706.0,
"duration": 1.98
},
{
"text": "And so here's basically\nthe steps that I go through",
"start": 5707.98,
"duration": 3.15
},
{
"text": "in order to figure out what I should\nuse when working on my own project.",
"start": 5711.13,
"duration": 4.09
},
{
"text": "So first have a goal in mind.",
"start": 5715.22,
"duration": 1.832
},
{
"text": "You need to know what problem\nyou're trying to solve.",
"start": 5717.052,
"duration": 2.208
},
{
"text": "Otherwise reading a bunch\nabout what's offered",
"start": 5719.26,
"duration": 2.31
},
{
"text": "doesn't really mean anything to you.",
"start": 5721.57,
"duration": 1.86
},
{
"text": "And so say you were doing\nsomething like the TODO app",
"start": 5723.43,
"duration": 3.09
},
{
"text": "that we did before the first\nthing that you'll notice",
"start": 5726.52,
"duration": 3.6
},
{
"text": "is that there is no input\ntype checkbox in React Native.",
"start": 5730.12,
"duration": 3.7
},
{
"text": "And so you have to figure\nout what is my goal here?",
"start": 5733.82,
"duration": 2.57
},
{
"text": "Well I want to replace\nwhat used to be a checkbox.",
"start": 5736.39,
"duration": 4.91
},
{
"text": "And so your goal in that\nexample would be all right",
"start": 5741.3,
"duration": 2.77
},
{
"text": "I need some component that\nbasically just renders a Boolean.",
"start": 5744.07,
"duration": 4.62
},
{
"text": "Then just see what the\nlibrary or framework offers.",
"start": 5748.69,
"duration": 2.72
},
{
"text": "And so the way I did that was I\njust browsed through the docs.",
"start": 5751.41,
"duration": 3.77
},
{
"text": "So they're linked in this presentation.",
"start": 5755.18,
"duration": 2.87
},
{
"text": "I'll go ahead and link them in\nthe Resources tab on the website.",
"start": 5758.05,
"duration": 3.51
},
{
"text": "But just see exactly what the library\nhas to offer, see what they have,",
"start": 5761.56,
"duration": 4.755
},
{
"text": "then find something that\nsolves your problem.",
"start": 5766.315,
"duration": 1.875
},
{
"text": "There may be multiple things\nthat solve your problem",
"start": 5768.19,
"duration": 2.19
},
{
"text": "but just try to find the thing\nthat best solves your problem.",
"start": 5770.38,
"duration": 2.88
},
{
"text": "And so in my case for that\nparticular Boolean switch",
"start": 5773.26,
"duration": 3.09
},
{
"text": "I saw that they had something\ncalled a switch that",
"start": 5776.35,
"duration": 2.49
},
{
"text": "just renders a Boolean flag that you\ncan just tap and then configure it.",
"start": 5778.84,
"duration": 8.43
},
{
"text": "And so the docs will\ntell you exactly what",
"start": 5787.27,
"duration": 2.73
},
{
"text": "the API is, how you can configure\nit, what properties you have to set.",
"start": 5790.0,
"duration": 3.42
},
{
"text": "And so for switch we had the value\nwhich was either true or false.",
"start": 5793.42,
"duration": 4.37
},
{
"text": "And we had on value change which was, I\nbelieve, the name of the prop that gets",
"start": 5797.79,
"duration": 4.9
},
{
"text": "called every single time\nyou change that value.",
"start": 5802.69,
"duration": 3.31
},
{
"text": "And so it just fit that API\nto whatever you're using.",
"start": 5806.0,
"duration": 6.83
},
{
"text": "And then, of course, if you\nhave trouble even then, then",
"start": 5812.83,
"duration": 3.06
},
{
"text": "you can turn to the community.",
"start": 5815.89,
"duration": 1.83
},
{
"text": "A great thing about React,\nReact Native is the community.",
"start": 5817.72,
"duration": 3.584
},
{
"text": "Lots and lots of people use\nReact, lots and lots of people",
"start": 5821.304,
"duration": 2.416
},
{
"text": "use React Native and a\nlot of them are experts",
"start": 5823.72,
"duration": 3.942
},
{
"text": "who were once beginners themselves.",
"start": 5827.662,
"duration": 1.458
},
{
"text": "And everybody remembers when they\nwere first learning React and React",
"start": 5829.12,
"duration": 3.23
},
{
"text": "Native there's just a\nlot around and there's",
"start": 5832.35,
"duration": 2.38
},
{
"text": "a lot of stuff in the ecosystem.",
"start": 5834.73,
"duration": 2.04
},
{
"text": "And the community's really great in\nhelping each other learn what's around",
"start": 5836.77,
"duration": 5.13
},
{
"text": "and how to best solve their problems.",
"start": 5841.9,
"duration": 1.612
},
{
"text": "And so just ask the question.",
"start": 5843.512,
"duration": 1.208
},
{
"text": "You can ask it in Slack\nif you're part of a class.",
"start": 5844.72,
"duration": 2.76
},
{
"text": "You can ask it on something like\nStack Overflow or just Google around.",
"start": 5847.48,
"duration": 4.299
},
{
"text": "And so if you run into a\nproblem odds are somebody else",
"start": 5851.779,
"duration": 2.291
},
{
"text": "has already run into the problem and\nodds are somebody better than you,",
"start": 5854.07,
"duration": 4.93
},
{
"text": "better than I have solved that problem.",
"start": 5859.0,
"duration": 2.47
},
{
"text": "And you can go ahead\nand use their solution.",
"start": 5861.47,
"duration": 3.89
},
{
"text": "And so any time you get stuck\nfeel free to either browse",
"start": 5865.36,
"duration": 4.44
},
{
"text": "the documentation yourself or reach\nout to the staff with any questions.",
"start": 5869.8,
"duration": 5.82
},
{
"text": "And so, yeah, that's all\nI have for you today.",
"start": 5875.62,
"duration": 3.49
},
{
"text": "Good luck starting your project.",
"start": 5879.11,
"duration": 1.61
},
{
"text": "It will be released before next Monday.",
"start": 5880.72,
"duration": 3.32
}
] |