{"componentChunkName":"component---src-gatsby-theme-try-ghost-templates-post-js","path":"/5-tips-to-become-a-react-native-developer/","result":{"data":{"customPost":{"id":"Ghost__Post__615c9bad3eea8f060129b2cd","title":"5 Tips To Become A React Native Developer","slug":"5-tips-to-become-a-react-native-developer","featured":false,"feature_image":"https://backend.shahednasser.com/content/images/2021/10/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.jpg","excerpt":"If you are considering learning how to build android or iOS apps using React Native then this article is for you.","custom_excerpt":"If you are considering learning how to build android or iOS apps using React Native then this article is for you.","visibility":"public","created_at_pretty":"5 Oct 2021","published_at_pretty":"7 Oct 2021","updated_at_pretty":"7 Oct 2021","created_at":"2021-10-05T18:38:37.000+00:00","published_at":"2021-10-07T13:31:24.000+00:00","updated_at":"2021-10-07T13:31:24.000+00:00","meta_title":null,"meta_description":null,"og_description":null,"og_image":null,"og_title":null,"twitter_description":null,"twitter_image":null,"twitter_title":null,"authors":[{"slug":"chatty","url":"https://backend.shahednasser.com/author/chatty/","name":"Chatty Garrate","bio":"Chatty is a freelance writer from Manila. Aside from her job as a language evaluator for local and international students, she enjoys writing about various topics such as technology and business.","cover_image":null,"profile_image":"https://res-3.cloudinary.com/hbqmf3mbz/image/upload/q_auto/v1/ghost-blog-images/Chatty.jpg","location":null,"website":"http://www.linkedin.com/in/chatty-garrate1","twitter":"@ChattyGarrate","facebook":null,"meta_title":null,"meta_description":null,"coverImageSharp":null,"profileImageSharp":null}],"primary_author":{"slug":"chatty","url":"https://backend.shahednasser.com/author/chatty/","name":"Chatty Garrate","bio":"Chatty is a freelance writer from Manila. Aside from her job as a language evaluator for local and international students, she enjoys writing about various topics such as technology and business.","cover_image":null,"profile_image":"https://res-3.cloudinary.com/hbqmf3mbz/image/upload/q_auto/v1/ghost-blog-images/Chatty.jpg","location":null,"website":"http://www.linkedin.com/in/chatty-garrate1","twitter":"@ChattyGarrate","facebook":null,"meta_title":null,"meta_description":null,"coverImageSharp":null,"profileImageSharp":{"base":"Chatty.jpg","publicURL":"/static/a92cd25e7fe77c940c3b8b961a548c14/Chatty.jpg","imageMeta":{"width":648,"height":648},"childImageSharp":{"fluid":{"base64":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAUABQDASIAAhEBAxEB/8QAGAABAAMBAAAAAAAAAAAAAAAAAAEDBAX/xAAUAQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIQAxAAAAHJz9lBmQL6QgH/xAAbEAABBQEBAAAAAAAAAAAAAAABAAIDERIQIv/aAAgBAQABBQIny8UVG7RnrS0c8//EABQRAQAAAAAAAAAAAAAAAAAAACD/2gAIAQMBAT8BH//EABQRAQAAAAAAAAAAAAAAAAAAACD/2gAIAQIBAT8BH//EABsQAAIBBQAAAAAAAAAAAAAAAAABECAhYXGR/9oACAEBAAY/AnwxGizp/8QAHBABAAEFAQEAAAAAAAAAAAAAASEAEDFBURFh/9oACAEBAAE/IQNa5VhhPqwcmVQJHyTlnept/9oADAMBAAIAAwAAABDQzzz/xAAUEQEAAAAAAAAAAAAAAAAAAAAg/9oACAEDAQE/EB//xAAUEQEAAAAAAAAAAAAAAAAAAAAg/9oACAECAQE/EB//xAAeEAEAAgICAwEAAAAAAAAAAAABABEhQRBxMWGBwf/aAAgBAQABPxB+0xsG0+S4tlVvCC6V1PZ3DZVsr9cKJjrES+e+P//Z","aspectRatio":1,"src":"/static/a92cd25e7fe77c940c3b8b961a548c14/31709/Chatty.jpg","srcSet":"/static/a92cd25e7fe77c940c3b8b961a548c14/f340b/Chatty.jpg 28w,\n/static/a92cd25e7fe77c940c3b8b961a548c14/22d64/Chatty.jpg 55w,\n/static/a92cd25e7fe77c940c3b8b961a548c14/31709/Chatty.jpg 110w,\n/static/a92cd25e7fe77c940c3b8b961a548c14/aa249/Chatty.jpg 165w,\n/static/a92cd25e7fe77c940c3b8b961a548c14/0dc33/Chatty.jpg 220w,\n/static/a92cd25e7fe77c940c3b8b961a548c14/5fcae/Chatty.jpg 648w","srcWebp":"/static/a92cd25e7fe77c940c3b8b961a548c14/8678c/Chatty.webp","srcSetWebp":"/static/a92cd25e7fe77c940c3b8b961a548c14/59cda/Chatty.webp 28w,\n/static/a92cd25e7fe77c940c3b8b961a548c14/7da75/Chatty.webp 55w,\n/static/a92cd25e7fe77c940c3b8b961a548c14/8678c/Chatty.webp 110w,\n/static/a92cd25e7fe77c940c3b8b961a548c14/f282e/Chatty.webp 165w,\n/static/a92cd25e7fe77c940c3b8b961a548c14/a7b21/Chatty.webp 220w,\n/static/a92cd25e7fe77c940c3b8b961a548c14/891ac/Chatty.webp 648w","sizes":"(max-width: 110px) 100vw, 110px"}}}},"primary_tag":{"slug":"react-native","url":"https://backend.shahednasser.com/tag/react-native/","name":"React Native","visibility":"public","feature_image":null,"description":null,"meta_title":null,"meta_description":null,"featureImageSharp":null},"tags":[{"slug":"react-native","url":"https://backend.shahednasser.com/tag/react-native/","name":"React Native","visibility":"public","feature_image":null,"description":null,"meta_title":null,"meta_description":null,"featureImageSharp":null},{"slug":"beginner","url":"https://backend.shahednasser.com/tag/beginner/","name":"Beginners","visibility":"public","feature_image":"https://backend.shahednasser.com/content/images/2022/01/photo-1521185496955-15097b20c5fe-2.jpeg","description":"Tutorials, articles, and tips to help beginners accelerate their journey in programming.","meta_title":"Beginners","meta_description":"Tutorials, articles, and tips to help beginners accelerate their journey in programming.","featureImageSharp":null}],"plaintext":"React Native [https://reactnative.dev] is a cross-platform mobile application\ndevelopment framework. The main advantage of this technology is that you can use\nthe same code base on all platforms without any changes. This makes your app\nmore scalable and cost-effective because you don’t have to write separate codes\nfor each device which will save time and money. \n\nReact Native developers [https://andela.com/react-native-developers/] are in\nhigh demand these days because it has become one of the most popular\ntechnologies among web designers, front end engineers, and back-end programmers.\nIf you are considering learning how to build android or iOS apps using React\nNative then this article is for you.\n\nWhat Is React Native?\nBefore we can talk about becoming a React Native developer, let us first take a\nlook at what exactly React Native is. It's a framework that allows developers to\nbuild cross-platform applications by combining web technologies like JavaScript\nalong with native code written specifically for iOS or Android devices. \n\nThe reason why so many people have been switching over to React Native is that\nit has made creating cross-platform mobile apps much easier than ever before.\nWith React Native, you no longer need to write separate codes for each operating\nsystem. Instead, you just develop one set of code that works across multiple\nplatforms.\n\nTips for Becoming a React Native Developer\nIf you're thinking about learning to develop apps using React Native, there are\nseveral things you have to keep in mind. These tips will help you get started\nwith the framework and become an expert developer in no time:\n\nLearn JavaScript First\nBefore starting on your journey of becoming a React Native developer, it's\nimportant that you learn how to program in general. This is because React Native\nuses JavaScript as its primary language. If you don't know JavaScript well\nenough, then this could be quite difficult for you. Learning JavaScript before\ngetting into React Native can save you from having to deal with some common\nissues when developing apps.\n\nYou can learn JavaScript by reading books or online tutorials. There are many\ngreat resources available and the best way to find them is to search Google. You\nshould also try to get familiar with other programming languages such as Java,\nPython, and C so that you have an idea about what they're like. The more\nexperience you gain, the better prepared you'll be for learning React Native.\n\n[https://edabit.com/challenges/javascript?ref=shahednasser1&tap_a=86255-ae3f95]\nUnderstand What Makes React Native Different\nWhen compared to other mobile app development platforms, React Native has a few\nunique features which make it stand apart. One such feature is that it allows\ndevelopers to use native components, instead of building their own custom ones.\nAnd since React Native uses JavaScript as its primary language, you can build\napps for iOS and Android using the same codebase. This makes your life much\neasier when developing an application because you don't have to write separate\ncodes for each platform.\n\nFamiliarize Yourself with the Official Documentation\nThe official docs contain all sorts of information regarding everything related\nto React Native. You should definitely spend time reading through them so that\nyou understand every aspect of the platform. They also provide tutorials and\nguides for beginners who want to start off right away.\n\nWatching or reading a React Native tutorial\n[https://blog.shahednasser.com/react-native-tutorial-create-your-first-app/] \nwill also give you a good understanding of the basics of the framework. It will\nteach you how to create basic UI elements and connect them together. Once you've\nmastered these concepts, you can move on to advanced topics such as animations,\ndata binding, and more.\n\nLearning About Navigation Concepts\nAs mentioned earlier, one of the most interesting aspects of React Native is\nthat it provides access to many built-in navigation concepts. Both these methods\nwork very similarly to those used in regular web applications. However, they\nallow us to build more complex user interfaces without needing to write much\ncode ourselves.\n\nLearning about different navigation concepts can be a bit overwhelming at first\nbut once you understand them and how they are implemented, using them becomes\nsecond nature. This will help you get started with building your own apps\nfaster.\n\nChallenge Yourself to Complete React Native Projects\nLearning any skill takes practice. So if you really want to master something,\nyou need to put in lots of effort. To do this, challenge yourself to work on\nvarious projects with React Native. Try creating simple games or chat\napplications. Doing so will not only improve your skills but also expose you to\nnew ideas and techniques.\n\nIf you feel stuck at any point while working on a particular task, reach out to\nyour friends or colleagues. Ask them questions and see whether they can help you\nfigure things out. Chances are, someone else might already have faced similar\nproblems and solved them. In addition, asking people around you helps you\ndevelop confidence in your abilities.\n\nConclusion\nReact Native is one of the most popular cross-platform frameworks that will\nallow you to create beautiful, highly performant apps, as well as find jobs\neasily in the market. Start your journey now\n[https://blog.shahednasser.com/react-native-tutorial-create-your-first-app/]!","html":"<p><a href=\"https://reactnative.dev\">React Native</a> is a cross-platform mobile application development framework. The main advantage of this technology is that you can use the same code base on all platforms without any changes. This makes your app more scalable and cost-effective because you don’t have to write separate codes for each device which will save time and money. </p><p><a href=\"https://andela.com/react-native-developers/\">React Native developers</a> are in high demand these days because it has become one of the most popular technologies among web designers, front end engineers, and back-end programmers. If you are considering learning how to build android or iOS apps using React Native then this article is for you.</p><h2 id=\"what-is-react-native\">What Is React Native?</h2><p>Before we can talk about becoming a React Native developer, let us first take a look at what exactly React Native is. It's a framework that allows developers to build cross-platform applications by combining web technologies like JavaScript along with native code written specifically for iOS or Android devices. </p><p>The reason why so many people have been switching over to React Native is that it has made creating cross-platform mobile apps much easier than ever before. With React Native, you no longer need to write separate codes for each operating system. Instead, you just develop one set of code that works across multiple platforms.</p><h2 id=\"tips-for-becoming-a-react-native-developer\">Tips for Becoming a React Native Developer</h2><p>If you're thinking about learning to develop apps using React Native, there are several things you have to keep in mind. These tips will help you get started with the framework and become an expert developer in no time:</p><h3 id=\"learn-javascript-first\">Learn JavaScript First</h3><p>Before starting on your journey of becoming a React Native developer, it's important that you learn how to program in general. This is because React Native uses JavaScript as its primary language. If you don't know JavaScript well enough, then this could be quite difficult for you. Learning JavaScript before getting into React Native can save you from having to deal with some common issues when developing apps.</p><p>You can learn JavaScript by reading books or online tutorials. There are many great resources available and the best way to find them is to search Google. You should also try to get familiar with other programming languages such as Java, Python, and C so that you have an idea about what they're like. The more experience you gain, the better prepared you'll be for learning React Native.</p><!--kg-card-begin: html--><a href=\"https://edabit.com/challenges/javascript?ref=shahednasser1&tap_a=86255-ae3f95\" target=\"_BLANK\" rel=\"nofollow\"><img src=\"https://static.tapfiliate.com/5fcf4fb9056cd927104425.png?a=86255-ae3f95&s=2171241-632e37\" border=\"0\"></a><!--kg-card-end: html--><h3 id=\"understand-what-makes-react-native-different\">Understand What Makes React Native Different</h3><p>When compared to other mobile app development platforms, React Native has a few unique features which make it stand apart. One such feature is that it allows developers to use native components, instead of building their own custom ones. And since React Native uses JavaScript as its primary language, you can build apps for iOS and Android using the same codebase. This makes your life much easier when developing an application because you don't have to write separate codes for each platform.</p><h3 id=\"familiarize-yourself-with-the-official-documentation\">Familiarize Yourself with the Official Documentation</h3><p>The official docs contain all sorts of information regarding everything related to React Native. You should definitely spend time reading through them so that you understand every aspect of the platform. They also provide tutorials and guides for beginners who want to start off right away.</p><p>Watching or reading a <a href=\"https://blog.shahednasser.com/react-native-tutorial-create-your-first-app/\">React Native tutorial</a> will also give you a good understanding of the basics of the framework. It will teach you how to create basic UI elements and connect them together. Once you've mastered these concepts, you can move on to advanced topics such as animations, data binding, and more.</p><h3 id=\"learning-about-navigation-concepts\">Learning About Navigation Concepts</h3><p>As mentioned earlier, one of the most interesting aspects of React Native is that it provides access to many built-in navigation concepts. Both these methods work very similarly to those used in regular web applications. However, they allow us to build more complex user interfaces without needing to write much code ourselves.</p><p>Learning about different navigation concepts can be a bit overwhelming at first but once you understand them and how they are implemented, using them becomes second nature. This will help you get started with building your own apps faster.</p><h3 id=\"challenge-yourself-to-complete-react-native-projects\">Challenge Yourself to Complete React Native Projects</h3><p>Learning any skill takes practice. So if you really want to master something, you need to put in lots of effort. To do this, challenge yourself to work on various projects with React Native. Try creating simple games or chat applications. Doing so will not only improve your skills but also expose you to new ideas and techniques.</p><p>If you feel stuck at any point while working on a particular task, reach out to your friends or colleagues. Ask them questions and see whether they can help you figure things out. Chances are, someone else might already have faced similar problems and solved them. In addition, asking people around you helps you develop confidence in your abilities.</p><h2 id=\"conclusion\">Conclusion</h2><p>React Native is one of the most popular cross-platform frameworks that will allow you to create beautiful, highly performant apps, as well as find jobs easily in the market. <a href=\"https://blog.shahednasser.com/react-native-tutorial-create-your-first-app/\">Start your journey now</a>!</p>","url":"https://backend.shahednasser.com/5-tips-to-become-a-react-native-developer/","canonical_url":null,"uuid":"76cec4d4-7cd1-4594-afca-51124a022186","codeinjection_foot":null,"codeinjection_head":null,"codeinjection_styles":null,"comment_id":"615c9bad3eea8f060129b2cd","reading_time":4,"send_email_when_published":null,"email_subject":null,"childHtmlRehype":{"html":"<p><a href=\"https://reactnative.dev\">React Native</a> is a cross-platform mobile application development framework. The main advantage of this technology is that you can use the same code base on all platforms without any changes. This makes your app more scalable and cost-effective because you don’t have to write separate codes for each device which will save time and money. </p><p><a href=\"https://andela.com/react-native-developers/\">React Native developers</a> are in high demand these days because it has become one of the most popular technologies among web designers, front end engineers, and back-end programmers. If you are considering learning how to build android or iOS apps using React Native then this article is for you.</p><h2 id=\"what-is-react-native\">What Is React Native?</h2><p>Before we can talk about becoming a React Native developer, let us first take a look at what exactly React Native is. It's a framework that allows developers to build cross-platform applications by combining web technologies like JavaScript along with native code written specifically for iOS or Android devices. </p><p>The reason why so many people have been switching over to React Native is that it has made creating cross-platform mobile apps much easier than ever before. With React Native, you no longer need to write separate codes for each operating system. Instead, you just develop one set of code that works across multiple platforms.</p><h2 id=\"tips-for-becoming-a-react-native-developer\">Tips for Becoming a React Native Developer</h2><p>If you're thinking about learning to develop apps using React Native, there are several things you have to keep in mind. These tips will help you get started with the framework and become an expert developer in no time:</p><h3 id=\"learn-javascript-first\">Learn JavaScript First</h3><p>Before starting on your journey of becoming a React Native developer, it's important that you learn how to program in general. This is because React Native uses JavaScript as its primary language. If you don't know JavaScript well enough, then this could be quite difficult for you. Learning JavaScript before getting into React Native can save you from having to deal with some common issues when developing apps.</p><p>You can learn JavaScript by reading books or online tutorials. There are many great resources available and the best way to find them is to search Google. You should also try to get familiar with other programming languages such as Java, Python, and C so that you have an idea about what they're like. The more experience you gain, the better prepared you'll be for learning React Native.</p><!--kg-card-begin: html--><a href=\"https://edabit.com/challenges/javascript?ref=shahednasser1&#x26;tap_a=86255-ae3f95\" target=\"_BLANK\" rel=\"nofollow\"><img src=\"https://static.tapfiliate.com/5fcf4fb9056cd927104425.png?a=86255-ae3f95&#x26;s=2171241-632e37\" border=\"0\"></a><!--kg-card-end: html--><h3 id=\"understand-what-makes-react-native-different\">Understand What Makes React Native Different</h3><p>When compared to other mobile app development platforms, React Native has a few unique features which make it stand apart. One such feature is that it allows developers to use native components, instead of building their own custom ones. And since React Native uses JavaScript as its primary language, you can build apps for iOS and Android using the same codebase. This makes your life much easier when developing an application because you don't have to write separate codes for each platform.</p><h3 id=\"familiarize-yourself-with-the-official-documentation\">Familiarize Yourself with the Official Documentation</h3><p>The official docs contain all sorts of information regarding everything related to React Native. You should definitely spend time reading through them so that you understand every aspect of the platform. They also provide tutorials and guides for beginners who want to start off right away.</p><p>Watching or reading a <a href=\"https://blog.shahednasser.com/react-native-tutorial-create-your-first-app/\">React Native tutorial</a> will also give you a good understanding of the basics of the framework. It will teach you how to create basic UI elements and connect them together. Once you've mastered these concepts, you can move on to advanced topics such as animations, data binding, and more.</p><h3 id=\"learning-about-navigation-concepts\">Learning About Navigation Concepts</h3><p>As mentioned earlier, one of the most interesting aspects of React Native is that it provides access to many built-in navigation concepts. Both these methods work very similarly to those used in regular web applications. However, they allow us to build more complex user interfaces without needing to write much code ourselves.</p><p>Learning about different navigation concepts can be a bit overwhelming at first but once you understand them and how they are implemented, using them becomes second nature. This will help you get started with building your own apps faster.</p><h3 id=\"challenge-yourself-to-complete-react-native-projects\">Challenge Yourself to Complete React Native Projects</h3><p>Learning any skill takes practice. So if you really want to master something, you need to put in lots of effort. To do this, challenge yourself to work on various projects with React Native. Try creating simple games or chat applications. Doing so will not only improve your skills but also expose you to new ideas and techniques.</p><p>If you feel stuck at any point while working on a particular task, reach out to your friends or colleagues. Ask them questions and see whether they can help you figure things out. Chances are, someone else might already have faced similar problems and solved them. In addition, asking people around you helps you develop confidence in your abilities.</p><h2 id=\"conclusion\">Conclusion</h2><p>React Native is one of the most popular cross-platform frameworks that will allow you to create beautiful, highly performant apps, as well as find jobs easily in the market. <a href=\"https://blog.shahednasser.com/react-native-tutorial-create-your-first-app/\">Start your journey now</a>!</p>","htmlAst":{"type":"root","children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"https://reactnative.dev"},"children":[{"type":"text","value":"React Native"}]},{"type":"text","value":" is a cross-platform mobile application development framework. The main advantage of this technology is that you can use the same code base on all platforms without any changes. This makes your app more scalable and cost-effective because you don’t have to write separate codes for each device which will save time and money. "}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"https://andela.com/react-native-developers/"},"children":[{"type":"text","value":"React Native developers"}]},{"type":"text","value":" are in high demand these days because it has become one of the most popular technologies among web designers, front end engineers, and back-end programmers. If you are considering learning how to build android or iOS apps using React Native then this article is for you."}]},{"type":"element","tagName":"h2","properties":{"id":"what-is-react-native"},"children":[{"type":"text","value":"What Is React Native?"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Before we can talk about becoming a React Native developer, let us first take a look at what exactly React Native is. It's a framework that allows developers to build cross-platform applications by combining web technologies like JavaScript along with native code written specifically for iOS or Android devices. "}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The reason why so many people have been switching over to React Native is that it has made creating cross-platform mobile apps much easier than ever before. With React Native, you no longer need to write separate codes for each operating system. Instead, you just develop one set of code that works across multiple platforms."}]},{"type":"element","tagName":"h2","properties":{"id":"tips-for-becoming-a-react-native-developer"},"children":[{"type":"text","value":"Tips for Becoming a React Native Developer"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If you're thinking about learning to develop apps using React Native, there are several things you have to keep in mind. These tips will help you get started with the framework and become an expert developer in no time:"}]},{"type":"element","tagName":"h3","properties":{"id":"learn-javascript-first"},"children":[{"type":"text","value":"Learn JavaScript First"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Before starting on your journey of becoming a React Native developer, it's important that you learn how to program in general. This is because React Native uses JavaScript as its primary language. If you don't know JavaScript well enough, then this could be quite difficult for you. Learning JavaScript before getting into React Native can save you from having to deal with some common issues when developing apps."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can learn JavaScript by reading books or online tutorials. There are many great resources available and the best way to find them is to search Google. You should also try to get familiar with other programming languages such as Java, Python, and C so that you have an idea about what they're like. The more experience you gain, the better prepared you'll be for learning React Native."}]},{"type":"comment","value":"kg-card-begin: html"},{"type":"element","tagName":"a","properties":{"href":"https://edabit.com/challenges/javascript?ref=shahednasser1&tap_a=86255-ae3f95","target":"_BLANK","rel":["nofollow"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://static.tapfiliate.com/5fcf4fb9056cd927104425.png?a=86255-ae3f95&s=2171241-632e37","border":0},"children":[]}]},{"type":"comment","value":"kg-card-end: html"},{"type":"element","tagName":"h3","properties":{"id":"understand-what-makes-react-native-different"},"children":[{"type":"text","value":"Understand What Makes React Native Different"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"When compared to other mobile app development platforms, React Native has a few unique features which make it stand apart. One such feature is that it allows developers to use native components, instead of building their own custom ones. And since React Native uses JavaScript as its primary language, you can build apps for iOS and Android using the same codebase. This makes your life much easier when developing an application because you don't have to write separate codes for each platform."}]},{"type":"element","tagName":"h3","properties":{"id":"familiarize-yourself-with-the-official-documentation"},"children":[{"type":"text","value":"Familiarize Yourself with the Official Documentation"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The official docs contain all sorts of information regarding everything related to React Native. You should definitely spend time reading through them so that you understand every aspect of the platform. They also provide tutorials and guides for beginners who want to start off right away."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Watching or reading a "},{"type":"element","tagName":"a","properties":{"href":"https://blog.shahednasser.com/react-native-tutorial-create-your-first-app/"},"children":[{"type":"text","value":"React Native tutorial"}]},{"type":"text","value":" will also give you a good understanding of the basics of the framework. It will teach you how to create basic UI elements and connect them together. Once you've mastered these concepts, you can move on to advanced topics such as animations, data binding, and more."}]},{"type":"element","tagName":"h3","properties":{"id":"learning-about-navigation-concepts"},"children":[{"type":"text","value":"Learning About Navigation Concepts"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"As mentioned earlier, one of the most interesting aspects of React Native is that it provides access to many built-in navigation concepts. Both these methods work very similarly to those used in regular web applications. However, they allow us to build more complex user interfaces without needing to write much code ourselves."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Learning about different navigation concepts can be a bit overwhelming at first but once you understand them and how they are implemented, using them becomes second nature. This will help you get started with building your own apps faster."}]},{"type":"element","tagName":"h3","properties":{"id":"challenge-yourself-to-complete-react-native-projects"},"children":[{"type":"text","value":"Challenge Yourself to Complete React Native Projects"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Learning any skill takes practice. So if you really want to master something, you need to put in lots of effort. To do this, challenge yourself to work on various projects with React Native. Try creating simple games or chat applications. Doing so will not only improve your skills but also expose you to new ideas and techniques."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If you feel stuck at any point while working on a particular task, reach out to your friends or colleagues. Ask them questions and see whether they can help you figure things out. Chances are, someone else might already have faced similar problems and solved them. In addition, asking people around you helps you develop confidence in your abilities."}]},{"type":"element","tagName":"h2","properties":{"id":"conclusion"},"children":[{"type":"text","value":"Conclusion"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"React Native is one of the most popular cross-platform frameworks that will allow you to create beautiful, highly performant apps, as well as find jobs easily in the market. "},{"type":"element","tagName":"a","properties":{"href":"https://blog.shahednasser.com/react-native-tutorial-create-your-first-app/"},"children":[{"type":"text","value":"Start your journey now"}]},{"type":"text","value":"!"}]}],"data":{"quirksMode":false}},"tableOfContents":[{"id":"what-is-react-native","heading":"What Is React Native?"},{"id":"tips-for-becoming-a-react-native-developer","heading":"Tips for Becoming a React Native Developer","items":[{"id":"learn-javascript-first","heading":"Learn JavaScript First"},{"id":"understand-what-makes-react-native-different","heading":"Understand What Makes React Native Different"},{"id":"familiarize-yourself-with-the-official-documentation","heading":"Familiarize Yourself with the Official Documentation"},{"id":"learning-about-navigation-concepts","heading":"Learning About Navigation Concepts"},{"id":"challenge-yourself-to-complete-react-native-projects","heading":"Challenge Yourself to Complete React Native Projects"}]},{"id":"conclusion","heading":"Conclusion"}]},"featureImageSharp":{"base":"christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.jpg","publicURL":"/static/59e21af85472edb4c0a7f8177d97000f/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.jpg","imageMeta":{"width":1920,"height":1282},"childImageSharp":{"fluid":{"base64":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAANABQDASIAAhEBAxEB/8QAGAAAAwEBAAAAAAAAAAAAAAAAAAMEAgX/xAAUAQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIQAxAAAAGtk3QNjA//xAAZEAACAwEAAAAAAAAAAAAAAAACEQADEAT/2gAIAQEAAQUCI3AJ5zqysRWf/8QAFREBAQAAAAAAAAAAAAAAAAAAARD/2gAIAQMBAT8BSf/EABURAQEAAAAAAAAAAAAAAAAAABAR/9oACAECAQE/Aaf/xAAbEAACAQUAAAAAAAAAAAAAAAAAAREQITFBcf/aAAgBAQAGPwJRJk2JtX7X/8QAGxAAAwEAAwEAAAAAAAAAAAAAAAERIUFRYeH/2gAIAQEAAT8hTJ3u2Ej9xjz6K7cKL8edMp//2gAMAwEAAgADAAAAEDQP/8QAFhEAAwAAAAAAAAAAAAAAAAAAARBB/9oACAEDAQE/EKhf/8QAFhEBAQEAAAAAAAAAAAAAAAAAARBB/9oACAECAQE/EDDP/8QAGxABAAMAAwEAAAAAAAAAAAAAAQARITFBkXH/2gAIAQEAAT8QOCuSqryAK9CDRs64iUFvDRQoodWancNFXNaV7Pif/9k=","aspectRatio":1.4942528735632183,"src":"/static/59e21af85472edb4c0a7f8177d97000f/d5c54/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.jpg","srcSet":"/static/59e21af85472edb4c0a7f8177d97000f/65d8c/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.jpg 260w,\n/static/59e21af85472edb4c0a7f8177d97000f/c5f21/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.jpg 520w,\n/static/59e21af85472edb4c0a7f8177d97000f/d5c54/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.jpg 1040w,\n/static/59e21af85472edb4c0a7f8177d97000f/81a53/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.jpg 1560w,\n/static/59e21af85472edb4c0a7f8177d97000f/74fd5/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.jpg 1920w","srcWebp":"/static/59e21af85472edb4c0a7f8177d97000f/e4875/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.webp","srcSetWebp":"/static/59e21af85472edb4c0a7f8177d97000f/dc8f3/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.webp 260w,\n/static/59e21af85472edb4c0a7f8177d97000f/2db4b/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.webp 520w,\n/static/59e21af85472edb4c0a7f8177d97000f/e4875/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.webp 1040w,\n/static/59e21af85472edb4c0a7f8177d97000f/f5845/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.webp 1560w,\n/static/59e21af85472edb4c0a7f8177d97000f/6833b/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.webp 1920w","sizes":"(max-width: 1040px) 100vw, 1040px"}}}},"ghostPost":{"id":"Ghost__Post__615c9bad3eea8f060129b2cd","title":"5 Tips To Become A React Native Developer","slug":"5-tips-to-become-a-react-native-developer","featured":false,"feature_image":"https://backend.shahednasser.com/content/images/2021/10/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.jpg","excerpt":"If you are considering learning how to build android or iOS apps using React Native then this article is for you.","custom_excerpt":"If you are considering learning how to build android or iOS apps using React Native then this article is for you.","visibility":"public","created_at_pretty":"5 Oct 2021","published_at_pretty":"7 Oct 2021","updated_at_pretty":"7 Oct 2021","created_at":"2021-10-05T18:38:37.000+00:00","published_at":"2021-10-07T13:31:24.000+00:00","updated_at":"2021-10-07T13:31:24.000+00:00","meta_title":null,"meta_description":null,"og_description":null,"og_image":null,"og_title":null,"twitter_description":null,"twitter_image":null,"twitter_title":null,"authors":[{"slug":"chatty","url":"https://backend.shahednasser.com/author/chatty/","name":"Chatty Garrate","bio":"Chatty is a freelance writer from Manila. Aside from her job as a language evaluator for local and international students, she enjoys writing about various topics such as technology and business.","cover_image":null,"profile_image":"https://res-3.cloudinary.com/hbqmf3mbz/image/upload/q_auto/v1/ghost-blog-images/Chatty.jpg","location":null,"website":"http://www.linkedin.com/in/chatty-garrate1","twitter":"@ChattyGarrate","facebook":null,"meta_title":null,"meta_description":null,"coverImageSharp":null,"profileImageSharp":null}],"primary_author":{"slug":"chatty","url":"https://backend.shahednasser.com/author/chatty/","name":"Chatty Garrate","bio":"Chatty is a freelance writer from Manila. Aside from her job as a language evaluator for local and international students, she enjoys writing about various topics such as technology and business.","cover_image":null,"profile_image":"https://res-3.cloudinary.com/hbqmf3mbz/image/upload/q_auto/v1/ghost-blog-images/Chatty.jpg","location":null,"website":"http://www.linkedin.com/in/chatty-garrate1","twitter":"@ChattyGarrate","facebook":null,"meta_title":null,"meta_description":null,"coverImageSharp":null,"profileImageSharp":{"base":"Chatty.jpg","publicURL":"/static/a92cd25e7fe77c940c3b8b961a548c14/Chatty.jpg","imageMeta":{"width":648,"height":648},"childImageSharp":{"fluid":{"base64":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAUABQDASIAAhEBAxEB/8QAGAABAAMBAAAAAAAAAAAAAAAAAAEDBAX/xAAUAQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIQAxAAAAHJz9lBmQL6QgH/xAAbEAABBQEBAAAAAAAAAAAAAAABAAIDERIQIv/aAAgBAQABBQIny8UVG7RnrS0c8//EABQRAQAAAAAAAAAAAAAAAAAAACD/2gAIAQMBAT8BH//EABQRAQAAAAAAAAAAAAAAAAAAACD/2gAIAQIBAT8BH//EABsQAAIBBQAAAAAAAAAAAAAAAAABECAhYXGR/9oACAEBAAY/AnwxGizp/8QAHBABAAEFAQEAAAAAAAAAAAAAASEAEDFBURFh/9oACAEBAAE/IQNa5VhhPqwcmVQJHyTlnept/9oADAMBAAIAAwAAABDQzzz/xAAUEQEAAAAAAAAAAAAAAAAAAAAg/9oACAEDAQE/EB//xAAUEQEAAAAAAAAAAAAAAAAAAAAg/9oACAECAQE/EB//xAAeEAEAAgICAwEAAAAAAAAAAAABABEhQRBxMWGBwf/aAAgBAQABPxB+0xsG0+S4tlVvCC6V1PZ3DZVsr9cKJjrES+e+P//Z","aspectRatio":1,"src":"/static/a92cd25e7fe77c940c3b8b961a548c14/31709/Chatty.jpg","srcSet":"/static/a92cd25e7fe77c940c3b8b961a548c14/f340b/Chatty.jpg 28w,\n/static/a92cd25e7fe77c940c3b8b961a548c14/22d64/Chatty.jpg 55w,\n/static/a92cd25e7fe77c940c3b8b961a548c14/31709/Chatty.jpg 110w,\n/static/a92cd25e7fe77c940c3b8b961a548c14/aa249/Chatty.jpg 165w,\n/static/a92cd25e7fe77c940c3b8b961a548c14/0dc33/Chatty.jpg 220w,\n/static/a92cd25e7fe77c940c3b8b961a548c14/5fcae/Chatty.jpg 648w","srcWebp":"/static/a92cd25e7fe77c940c3b8b961a548c14/8678c/Chatty.webp","srcSetWebp":"/static/a92cd25e7fe77c940c3b8b961a548c14/59cda/Chatty.webp 28w,\n/static/a92cd25e7fe77c940c3b8b961a548c14/7da75/Chatty.webp 55w,\n/static/a92cd25e7fe77c940c3b8b961a548c14/8678c/Chatty.webp 110w,\n/static/a92cd25e7fe77c940c3b8b961a548c14/f282e/Chatty.webp 165w,\n/static/a92cd25e7fe77c940c3b8b961a548c14/a7b21/Chatty.webp 220w,\n/static/a92cd25e7fe77c940c3b8b961a548c14/891ac/Chatty.webp 648w","sizes":"(max-width: 110px) 100vw, 110px"}}}},"primary_tag":{"slug":"react-native","url":"https://backend.shahednasser.com/tag/react-native/","name":"React Native","visibility":"public","feature_image":null,"description":null,"meta_title":null,"meta_description":null,"featureImageSharp":null},"tags":[{"slug":"react-native","url":"https://backend.shahednasser.com/tag/react-native/","name":"React Native","visibility":"public","feature_image":null,"description":null,"meta_title":null,"meta_description":null,"featureImageSharp":null},{"slug":"beginner","url":"https://backend.shahednasser.com/tag/beginner/","name":"Beginners","visibility":"public","feature_image":"https://backend.shahednasser.com/content/images/2022/01/photo-1521185496955-15097b20c5fe-2.jpeg","description":"Tutorials, articles, and tips to help beginners accelerate their journey in programming.","meta_title":"Beginners","meta_description":"Tutorials, articles, and tips to help beginners accelerate their journey in programming.","featureImageSharp":null}],"plaintext":"React Native [https://reactnative.dev] is a cross-platform mobile application\ndevelopment framework. The main advantage of this technology is that you can use\nthe same code base on all platforms without any changes. This makes your app\nmore scalable and cost-effective because you don’t have to write separate codes\nfor each device which will save time and money. \n\nReact Native developers [https://andela.com/react-native-developers/] are in\nhigh demand these days because it has become one of the most popular\ntechnologies among web designers, front end engineers, and back-end programmers.\nIf you are considering learning how to build android or iOS apps using React\nNative then this article is for you.\n\nWhat Is React Native?\nBefore we can talk about becoming a React Native developer, let us first take a\nlook at what exactly React Native is. It's a framework that allows developers to\nbuild cross-platform applications by combining web technologies like JavaScript\nalong with native code written specifically for iOS or Android devices. \n\nThe reason why so many people have been switching over to React Native is that\nit has made creating cross-platform mobile apps much easier than ever before.\nWith React Native, you no longer need to write separate codes for each operating\nsystem. Instead, you just develop one set of code that works across multiple\nplatforms.\n\nTips for Becoming a React Native Developer\nIf you're thinking about learning to develop apps using React Native, there are\nseveral things you have to keep in mind. These tips will help you get started\nwith the framework and become an expert developer in no time:\n\nLearn JavaScript First\nBefore starting on your journey of becoming a React Native developer, it's\nimportant that you learn how to program in general. This is because React Native\nuses JavaScript as its primary language. If you don't know JavaScript well\nenough, then this could be quite difficult for you. Learning JavaScript before\ngetting into React Native can save you from having to deal with some common\nissues when developing apps.\n\nYou can learn JavaScript by reading books or online tutorials. There are many\ngreat resources available and the best way to find them is to search Google. You\nshould also try to get familiar with other programming languages such as Java,\nPython, and C so that you have an idea about what they're like. The more\nexperience you gain, the better prepared you'll be for learning React Native.\n\n[https://edabit.com/challenges/javascript?ref=shahednasser1&tap_a=86255-ae3f95]\nUnderstand What Makes React Native Different\nWhen compared to other mobile app development platforms, React Native has a few\nunique features which make it stand apart. One such feature is that it allows\ndevelopers to use native components, instead of building their own custom ones.\nAnd since React Native uses JavaScript as its primary language, you can build\napps for iOS and Android using the same codebase. This makes your life much\neasier when developing an application because you don't have to write separate\ncodes for each platform.\n\nFamiliarize Yourself with the Official Documentation\nThe official docs contain all sorts of information regarding everything related\nto React Native. You should definitely spend time reading through them so that\nyou understand every aspect of the platform. They also provide tutorials and\nguides for beginners who want to start off right away.\n\nWatching or reading a React Native tutorial\n[https://blog.shahednasser.com/react-native-tutorial-create-your-first-app/] \nwill also give you a good understanding of the basics of the framework. It will\nteach you how to create basic UI elements and connect them together. Once you've\nmastered these concepts, you can move on to advanced topics such as animations,\ndata binding, and more.\n\nLearning About Navigation Concepts\nAs mentioned earlier, one of the most interesting aspects of React Native is\nthat it provides access to many built-in navigation concepts. Both these methods\nwork very similarly to those used in regular web applications. However, they\nallow us to build more complex user interfaces without needing to write much\ncode ourselves.\n\nLearning about different navigation concepts can be a bit overwhelming at first\nbut once you understand them and how they are implemented, using them becomes\nsecond nature. This will help you get started with building your own apps\nfaster.\n\nChallenge Yourself to Complete React Native Projects\nLearning any skill takes practice. So if you really want to master something,\nyou need to put in lots of effort. To do this, challenge yourself to work on\nvarious projects with React Native. Try creating simple games or chat\napplications. Doing so will not only improve your skills but also expose you to\nnew ideas and techniques.\n\nIf you feel stuck at any point while working on a particular task, reach out to\nyour friends or colleagues. Ask them questions and see whether they can help you\nfigure things out. Chances are, someone else might already have faced similar\nproblems and solved them. In addition, asking people around you helps you\ndevelop confidence in your abilities.\n\nConclusion\nReact Native is one of the most popular cross-platform frameworks that will\nallow you to create beautiful, highly performant apps, as well as find jobs\neasily in the market. Start your journey now\n[https://blog.shahednasser.com/react-native-tutorial-create-your-first-app/]!","html":"<p><a href=\"https://reactnative.dev\">React Native</a> is a cross-platform mobile application development framework. The main advantage of this technology is that you can use the same code base on all platforms without any changes. This makes your app more scalable and cost-effective because you don’t have to write separate codes for each device which will save time and money. </p><p><a href=\"https://andela.com/react-native-developers/\">React Native developers</a> are in high demand these days because it has become one of the most popular technologies among web designers, front end engineers, and back-end programmers. If you are considering learning how to build android or iOS apps using React Native then this article is for you.</p><h2 id=\"what-is-react-native\">What Is React Native?</h2><p>Before we can talk about becoming a React Native developer, let us first take a look at what exactly React Native is. It's a framework that allows developers to build cross-platform applications by combining web technologies like JavaScript along with native code written specifically for iOS or Android devices. </p><p>The reason why so many people have been switching over to React Native is that it has made creating cross-platform mobile apps much easier than ever before. With React Native, you no longer need to write separate codes for each operating system. Instead, you just develop one set of code that works across multiple platforms.</p><h2 id=\"tips-for-becoming-a-react-native-developer\">Tips for Becoming a React Native Developer</h2><p>If you're thinking about learning to develop apps using React Native, there are several things you have to keep in mind. These tips will help you get started with the framework and become an expert developer in no time:</p><h3 id=\"learn-javascript-first\">Learn JavaScript First</h3><p>Before starting on your journey of becoming a React Native developer, it's important that you learn how to program in general. This is because React Native uses JavaScript as its primary language. If you don't know JavaScript well enough, then this could be quite difficult for you. Learning JavaScript before getting into React Native can save you from having to deal with some common issues when developing apps.</p><p>You can learn JavaScript by reading books or online tutorials. There are many great resources available and the best way to find them is to search Google. You should also try to get familiar with other programming languages such as Java, Python, and C so that you have an idea about what they're like. The more experience you gain, the better prepared you'll be for learning React Native.</p><!--kg-card-begin: html--><a href=\"https://edabit.com/challenges/javascript?ref=shahednasser1&tap_a=86255-ae3f95\" target=\"_BLANK\" rel=\"nofollow\"><img src=\"https://static.tapfiliate.com/5fcf4fb9056cd927104425.png?a=86255-ae3f95&s=2171241-632e37\" border=\"0\"></a><!--kg-card-end: html--><h3 id=\"understand-what-makes-react-native-different\">Understand What Makes React Native Different</h3><p>When compared to other mobile app development platforms, React Native has a few unique features which make it stand apart. One such feature is that it allows developers to use native components, instead of building their own custom ones. And since React Native uses JavaScript as its primary language, you can build apps for iOS and Android using the same codebase. This makes your life much easier when developing an application because you don't have to write separate codes for each platform.</p><h3 id=\"familiarize-yourself-with-the-official-documentation\">Familiarize Yourself with the Official Documentation</h3><p>The official docs contain all sorts of information regarding everything related to React Native. You should definitely spend time reading through them so that you understand every aspect of the platform. They also provide tutorials and guides for beginners who want to start off right away.</p><p>Watching or reading a <a href=\"https://blog.shahednasser.com/react-native-tutorial-create-your-first-app/\">React Native tutorial</a> will also give you a good understanding of the basics of the framework. It will teach you how to create basic UI elements and connect them together. Once you've mastered these concepts, you can move on to advanced topics such as animations, data binding, and more.</p><h3 id=\"learning-about-navigation-concepts\">Learning About Navigation Concepts</h3><p>As mentioned earlier, one of the most interesting aspects of React Native is that it provides access to many built-in navigation concepts. Both these methods work very similarly to those used in regular web applications. However, they allow us to build more complex user interfaces without needing to write much code ourselves.</p><p>Learning about different navigation concepts can be a bit overwhelming at first but once you understand them and how they are implemented, using them becomes second nature. This will help you get started with building your own apps faster.</p><h3 id=\"challenge-yourself-to-complete-react-native-projects\">Challenge Yourself to Complete React Native Projects</h3><p>Learning any skill takes practice. So if you really want to master something, you need to put in lots of effort. To do this, challenge yourself to work on various projects with React Native. Try creating simple games or chat applications. Doing so will not only improve your skills but also expose you to new ideas and techniques.</p><p>If you feel stuck at any point while working on a particular task, reach out to your friends or colleagues. Ask them questions and see whether they can help you figure things out. Chances are, someone else might already have faced similar problems and solved them. In addition, asking people around you helps you develop confidence in your abilities.</p><h2 id=\"conclusion\">Conclusion</h2><p>React Native is one of the most popular cross-platform frameworks that will allow you to create beautiful, highly performant apps, as well as find jobs easily in the market. <a href=\"https://blog.shahednasser.com/react-native-tutorial-create-your-first-app/\">Start your journey now</a>!</p>","url":"https://backend.shahednasser.com/5-tips-to-become-a-react-native-developer/","canonical_url":null,"uuid":"76cec4d4-7cd1-4594-afca-51124a022186","codeinjection_foot":null,"codeinjection_head":null,"codeinjection_styles":null,"comment_id":"615c9bad3eea8f060129b2cd","reading_time":4,"send_email_when_published":null,"email_subject":null,"childHtmlRehype":{"html":"<p><a href=\"https://reactnative.dev\">React Native</a> is a cross-platform mobile application development framework. The main advantage of this technology is that you can use the same code base on all platforms without any changes. This makes your app more scalable and cost-effective because you don’t have to write separate codes for each device which will save time and money. </p><p><a href=\"https://andela.com/react-native-developers/\">React Native developers</a> are in high demand these days because it has become one of the most popular technologies among web designers, front end engineers, and back-end programmers. If you are considering learning how to build android or iOS apps using React Native then this article is for you.</p><h2 id=\"what-is-react-native\">What Is React Native?</h2><p>Before we can talk about becoming a React Native developer, let us first take a look at what exactly React Native is. It's a framework that allows developers to build cross-platform applications by combining web technologies like JavaScript along with native code written specifically for iOS or Android devices. </p><p>The reason why so many people have been switching over to React Native is that it has made creating cross-platform mobile apps much easier than ever before. With React Native, you no longer need to write separate codes for each operating system. Instead, you just develop one set of code that works across multiple platforms.</p><h2 id=\"tips-for-becoming-a-react-native-developer\">Tips for Becoming a React Native Developer</h2><p>If you're thinking about learning to develop apps using React Native, there are several things you have to keep in mind. These tips will help you get started with the framework and become an expert developer in no time:</p><h3 id=\"learn-javascript-first\">Learn JavaScript First</h3><p>Before starting on your journey of becoming a React Native developer, it's important that you learn how to program in general. This is because React Native uses JavaScript as its primary language. If you don't know JavaScript well enough, then this could be quite difficult for you. Learning JavaScript before getting into React Native can save you from having to deal with some common issues when developing apps.</p><p>You can learn JavaScript by reading books or online tutorials. There are many great resources available and the best way to find them is to search Google. You should also try to get familiar with other programming languages such as Java, Python, and C so that you have an idea about what they're like. The more experience you gain, the better prepared you'll be for learning React Native.</p><!--kg-card-begin: html--><a href=\"https://edabit.com/challenges/javascript?ref=shahednasser1&#x26;tap_a=86255-ae3f95\" target=\"_BLANK\" rel=\"nofollow\"><img src=\"https://static.tapfiliate.com/5fcf4fb9056cd927104425.png?a=86255-ae3f95&#x26;s=2171241-632e37\" border=\"0\"></a><!--kg-card-end: html--><h3 id=\"understand-what-makes-react-native-different\">Understand What Makes React Native Different</h3><p>When compared to other mobile app development platforms, React Native has a few unique features which make it stand apart. One such feature is that it allows developers to use native components, instead of building their own custom ones. And since React Native uses JavaScript as its primary language, you can build apps for iOS and Android using the same codebase. This makes your life much easier when developing an application because you don't have to write separate codes for each platform.</p><h3 id=\"familiarize-yourself-with-the-official-documentation\">Familiarize Yourself with the Official Documentation</h3><p>The official docs contain all sorts of information regarding everything related to React Native. You should definitely spend time reading through them so that you understand every aspect of the platform. They also provide tutorials and guides for beginners who want to start off right away.</p><p>Watching or reading a <a href=\"https://blog.shahednasser.com/react-native-tutorial-create-your-first-app/\">React Native tutorial</a> will also give you a good understanding of the basics of the framework. It will teach you how to create basic UI elements and connect them together. Once you've mastered these concepts, you can move on to advanced topics such as animations, data binding, and more.</p><h3 id=\"learning-about-navigation-concepts\">Learning About Navigation Concepts</h3><p>As mentioned earlier, one of the most interesting aspects of React Native is that it provides access to many built-in navigation concepts. Both these methods work very similarly to those used in regular web applications. However, they allow us to build more complex user interfaces without needing to write much code ourselves.</p><p>Learning about different navigation concepts can be a bit overwhelming at first but once you understand them and how they are implemented, using them becomes second nature. This will help you get started with building your own apps faster.</p><h3 id=\"challenge-yourself-to-complete-react-native-projects\">Challenge Yourself to Complete React Native Projects</h3><p>Learning any skill takes practice. So if you really want to master something, you need to put in lots of effort. To do this, challenge yourself to work on various projects with React Native. Try creating simple games or chat applications. Doing so will not only improve your skills but also expose you to new ideas and techniques.</p><p>If you feel stuck at any point while working on a particular task, reach out to your friends or colleagues. Ask them questions and see whether they can help you figure things out. Chances are, someone else might already have faced similar problems and solved them. In addition, asking people around you helps you develop confidence in your abilities.</p><h2 id=\"conclusion\">Conclusion</h2><p>React Native is one of the most popular cross-platform frameworks that will allow you to create beautiful, highly performant apps, as well as find jobs easily in the market. <a href=\"https://blog.shahednasser.com/react-native-tutorial-create-your-first-app/\">Start your journey now</a>!</p>","htmlAst":{"type":"root","children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"https://reactnative.dev"},"children":[{"type":"text","value":"React Native"}]},{"type":"text","value":" is a cross-platform mobile application development framework. The main advantage of this technology is that you can use the same code base on all platforms without any changes. This makes your app more scalable and cost-effective because you don’t have to write separate codes for each device which will save time and money. "}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"https://andela.com/react-native-developers/"},"children":[{"type":"text","value":"React Native developers"}]},{"type":"text","value":" are in high demand these days because it has become one of the most popular technologies among web designers, front end engineers, and back-end programmers. If you are considering learning how to build android or iOS apps using React Native then this article is for you."}]},{"type":"element","tagName":"h2","properties":{"id":"what-is-react-native"},"children":[{"type":"text","value":"What Is React Native?"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Before we can talk about becoming a React Native developer, let us first take a look at what exactly React Native is. It's a framework that allows developers to build cross-platform applications by combining web technologies like JavaScript along with native code written specifically for iOS or Android devices. "}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The reason why so many people have been switching over to React Native is that it has made creating cross-platform mobile apps much easier than ever before. With React Native, you no longer need to write separate codes for each operating system. Instead, you just develop one set of code that works across multiple platforms."}]},{"type":"element","tagName":"h2","properties":{"id":"tips-for-becoming-a-react-native-developer"},"children":[{"type":"text","value":"Tips for Becoming a React Native Developer"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If you're thinking about learning to develop apps using React Native, there are several things you have to keep in mind. These tips will help you get started with the framework and become an expert developer in no time:"}]},{"type":"element","tagName":"h3","properties":{"id":"learn-javascript-first"},"children":[{"type":"text","value":"Learn JavaScript First"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Before starting on your journey of becoming a React Native developer, it's important that you learn how to program in general. This is because React Native uses JavaScript as its primary language. If you don't know JavaScript well enough, then this could be quite difficult for you. Learning JavaScript before getting into React Native can save you from having to deal with some common issues when developing apps."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can learn JavaScript by reading books or online tutorials. There are many great resources available and the best way to find them is to search Google. You should also try to get familiar with other programming languages such as Java, Python, and C so that you have an idea about what they're like. The more experience you gain, the better prepared you'll be for learning React Native."}]},{"type":"comment","value":"kg-card-begin: html"},{"type":"element","tagName":"a","properties":{"href":"https://edabit.com/challenges/javascript?ref=shahednasser1&tap_a=86255-ae3f95","target":"_BLANK","rel":["nofollow"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://static.tapfiliate.com/5fcf4fb9056cd927104425.png?a=86255-ae3f95&s=2171241-632e37","border":0},"children":[]}]},{"type":"comment","value":"kg-card-end: html"},{"type":"element","tagName":"h3","properties":{"id":"understand-what-makes-react-native-different"},"children":[{"type":"text","value":"Understand What Makes React Native Different"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"When compared to other mobile app development platforms, React Native has a few unique features which make it stand apart. One such feature is that it allows developers to use native components, instead of building their own custom ones. And since React Native uses JavaScript as its primary language, you can build apps for iOS and Android using the same codebase. This makes your life much easier when developing an application because you don't have to write separate codes for each platform."}]},{"type":"element","tagName":"h3","properties":{"id":"familiarize-yourself-with-the-official-documentation"},"children":[{"type":"text","value":"Familiarize Yourself with the Official Documentation"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The official docs contain all sorts of information regarding everything related to React Native. You should definitely spend time reading through them so that you understand every aspect of the platform. They also provide tutorials and guides for beginners who want to start off right away."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Watching or reading a "},{"type":"element","tagName":"a","properties":{"href":"https://blog.shahednasser.com/react-native-tutorial-create-your-first-app/"},"children":[{"type":"text","value":"React Native tutorial"}]},{"type":"text","value":" will also give you a good understanding of the basics of the framework. It will teach you how to create basic UI elements and connect them together. Once you've mastered these concepts, you can move on to advanced topics such as animations, data binding, and more."}]},{"type":"element","tagName":"h3","properties":{"id":"learning-about-navigation-concepts"},"children":[{"type":"text","value":"Learning About Navigation Concepts"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"As mentioned earlier, one of the most interesting aspects of React Native is that it provides access to many built-in navigation concepts. Both these methods work very similarly to those used in regular web applications. However, they allow us to build more complex user interfaces without needing to write much code ourselves."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Learning about different navigation concepts can be a bit overwhelming at first but once you understand them and how they are implemented, using them becomes second nature. This will help you get started with building your own apps faster."}]},{"type":"element","tagName":"h3","properties":{"id":"challenge-yourself-to-complete-react-native-projects"},"children":[{"type":"text","value":"Challenge Yourself to Complete React Native Projects"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Learning any skill takes practice. So if you really want to master something, you need to put in lots of effort. To do this, challenge yourself to work on various projects with React Native. Try creating simple games or chat applications. Doing so will not only improve your skills but also expose you to new ideas and techniques."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If you feel stuck at any point while working on a particular task, reach out to your friends or colleagues. Ask them questions and see whether they can help you figure things out. Chances are, someone else might already have faced similar problems and solved them. In addition, asking people around you helps you develop confidence in your abilities."}]},{"type":"element","tagName":"h2","properties":{"id":"conclusion"},"children":[{"type":"text","value":"Conclusion"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"React Native is one of the most popular cross-platform frameworks that will allow you to create beautiful, highly performant apps, as well as find jobs easily in the market. "},{"type":"element","tagName":"a","properties":{"href":"https://blog.shahednasser.com/react-native-tutorial-create-your-first-app/"},"children":[{"type":"text","value":"Start your journey now"}]},{"type":"text","value":"!"}]}],"data":{"quirksMode":false}},"tableOfContents":[{"id":"what-is-react-native","heading":"What Is React Native?"},{"id":"tips-for-becoming-a-react-native-developer","heading":"Tips for Becoming a React Native Developer","items":[{"id":"learn-javascript-first","heading":"Learn JavaScript First"},{"id":"understand-what-makes-react-native-different","heading":"Understand What Makes React Native Different"},{"id":"familiarize-yourself-with-the-official-documentation","heading":"Familiarize Yourself with the Official Documentation"},{"id":"learning-about-navigation-concepts","heading":"Learning About Navigation Concepts"},{"id":"challenge-yourself-to-complete-react-native-projects","heading":"Challenge Yourself to Complete React Native Projects"}]},{"id":"conclusion","heading":"Conclusion"}]},"featureImageSharp":{"base":"christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.jpg","publicURL":"/static/59e21af85472edb4c0a7f8177d97000f/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.jpg","imageMeta":{"width":1920,"height":1282},"childImageSharp":{"fluid":{"base64":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAANABQDASIAAhEBAxEB/8QAGAAAAwEBAAAAAAAAAAAAAAAAAAMEAgX/xAAUAQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIQAxAAAAGtk3QNjA//xAAZEAACAwEAAAAAAAAAAAAAAAACEQADEAT/2gAIAQEAAQUCI3AJ5zqysRWf/8QAFREBAQAAAAAAAAAAAAAAAAAAARD/2gAIAQMBAT8BSf/EABURAQEAAAAAAAAAAAAAAAAAABAR/9oACAECAQE/Aaf/xAAbEAACAQUAAAAAAAAAAAAAAAAAAREQITFBcf/aAAgBAQAGPwJRJk2JtX7X/8QAGxAAAwEAAwEAAAAAAAAAAAAAAAERIUFRYeH/2gAIAQEAAT8hTJ3u2Ej9xjz6K7cKL8edMp//2gAMAwEAAgADAAAAEDQP/8QAFhEAAwAAAAAAAAAAAAAAAAAAARBB/9oACAEDAQE/EKhf/8QAFhEBAQEAAAAAAAAAAAAAAAAAARBB/9oACAECAQE/EDDP/8QAGxABAAMAAwEAAAAAAAAAAAAAAQARITFBkXH/2gAIAQEAAT8QOCuSqryAK9CDRs64iUFvDRQoodWancNFXNaV7Pif/9k=","aspectRatio":1.4942528735632183,"src":"/static/59e21af85472edb4c0a7f8177d97000f/d5c54/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.jpg","srcSet":"/static/59e21af85472edb4c0a7f8177d97000f/65d8c/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.jpg 260w,\n/static/59e21af85472edb4c0a7f8177d97000f/c5f21/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.jpg 520w,\n/static/59e21af85472edb4c0a7f8177d97000f/d5c54/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.jpg 1040w,\n/static/59e21af85472edb4c0a7f8177d97000f/81a53/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.jpg 1560w,\n/static/59e21af85472edb4c0a7f8177d97000f/74fd5/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.jpg 1920w","srcWebp":"/static/59e21af85472edb4c0a7f8177d97000f/e4875/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.webp","srcSetWebp":"/static/59e21af85472edb4c0a7f8177d97000f/dc8f3/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.webp 260w,\n/static/59e21af85472edb4c0a7f8177d97000f/2db4b/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.webp 520w,\n/static/59e21af85472edb4c0a7f8177d97000f/e4875/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.webp 1040w,\n/static/59e21af85472edb4c0a7f8177d97000f/f5845/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.webp 1560w,\n/static/59e21af85472edb4c0a7f8177d97000f/6833b/christina-wocintechchat-com-R_W_9D-53lw-unsplash-2.webp 1920w","sizes":"(max-width: 1040px) 100vw, 1040px"}}}},"prev":{"id":"Ghost__Post__6161d15b3eea8f060129b2fc","title":"Medusa: Create A Fast and Highly Customizable E-Commerce Store","slug":"medusa-create-fast-and-highly-customizable-ecommerce-store","featured":false,"feature_image":"https://backend.shahednasser.com/content/images/2021/10/Fast-and-Highly-Customizable-E-commerce-Stores.png","excerpt":"In this article, we'll briefly take a look at Medusa's structure, its pros, and its cons.","custom_excerpt":"In this article, we'll briefly take a look at Medusa's structure, its pros, and its cons.","visibility":"public","created_at_pretty":"9 Oct 2021","published_at_pretty":"11 Oct 2021","updated_at_pretty":"24 Mar 2022","created_at":"2021-10-09T17:28:59.000+00:00","published_at":"2021-10-11T16:00:38.000+00:00","updated_at":"2022-03-24T17:40:38.000+00:00","meta_title":null,"meta_description":null,"og_description":null,"og_image":null,"og_title":null,"twitter_description":null,"twitter_image":null,"twitter_title":null,"authors":[{"slug":"shahed","url":"https://backend.shahednasser.com/author/shahed/","name":"Shahed Nasser","bio":null,"cover_image":null,"profile_image":"https://backend.shahednasser.com/content/images/2022/03/IMG_0591.jpg","location":null,"website":null,"twitter":null,"facebook":null,"meta_title":null,"meta_description":null,"coverImageSharp":null,"profileImageSharp":null}],"primary_author":{"slug":"shahed","url":"https://backend.shahednasser.com/author/shahed/","name":"Shahed Nasser","bio":null,"cover_image":null,"profile_image":"https://backend.shahednasser.com/content/images/2022/03/IMG_0591.jpg","location":null,"website":null,"twitter":null,"facebook":null,"meta_title":null,"meta_description":null,"coverImageSharp":null,"profileImageSharp":{"base":"IMG_0591.jpg","publicURL":"/static/ceb49c3c631485453e71e00d7f84b069/IMG_0591.jpg","imageMeta":{"width":1182,"height":1179},"childImageSharp":{"fluid":{"base64":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAUABQDASIAAhEBAxEB/8QAGAABAQEBAQAAAAAAAAAAAAAAAAMEAQL/xAAWAQEBAQAAAAAAAAAAAAAAAAADBAL/2gAMAwEAAhADEAAAAdXiFM6i0CohUWXoKn//xAAcEAACAgIDAAAAAAAAAAAAAAACAwESBBEhM0H/2gAIAQEAAQUCWySE3WEr7SzbXjAj4iKty+sOQ//EABYRAQEBAAAAAAAAAAAAAAAAAAERIP/aAAgBAwEBPwEhj//EABQRAQAAAAAAAAAAAAAAAAAAACD/2gAIAQIBAT8BH//EAB4QAAIBBAMBAAAAAAAAAAAAAAABIRESMUECECJx/9oACAEBAAY/ApVGWvOjzgtUwLlTZA0sdL4f/8QAHBAAAwACAwEAAAAAAAAAAAAAAAERITFBkbHB/9oACAEBAAE/IahkCy+N2GwZpjQiJHJCspUFY0QrSi+HqiW2rgf/2gAMAwEAAgADAAAAEPw3/wD/xAAYEQEBAAMAAAAAAAAAAAAAAAAAARExQf/aAAgBAwEBPxCtjDqP/8QAFxEBAQEBAAAAAAAAAAAAAAAAAQAxEf/aAAgBAgEBPxBFus6Tt//EAB8QAQEAAgIBBQAAAAAAAAAAAAERACExQWFRcYGR0f/aAAgBAQABPxAuaBPPzkO1wyX7F4wkwXanfZrFQgeqE9JgS14vVOvrERIJomVBKwt2jebAeP0yVa8h1n//2Q==","aspectRatio":1,"src":"/static/ceb49c3c631485453e71e00d7f84b069/31709/IMG_0591.jpg","srcSet":"/static/ceb49c3c631485453e71e00d7f84b069/f340b/IMG_0591.jpg 28w,\n/static/ceb49c3c631485453e71e00d7f84b069/22d64/IMG_0591.jpg 55w,\n/static/ceb49c3c631485453e71e00d7f84b069/31709/IMG_0591.jpg 110w,\n/static/ceb49c3c631485453e71e00d7f84b069/aa249/IMG_0591.jpg 165w,\n/static/ceb49c3c631485453e71e00d7f84b069/0dc33/IMG_0591.jpg 220w,\n/static/ceb49c3c631485453e71e00d7f84b069/d8257/IMG_0591.jpg 1182w","srcWebp":"/static/ceb49c3c631485453e71e00d7f84b069/8678c/IMG_0591.webp","srcSetWebp":"/static/ceb49c3c631485453e71e00d7f84b069/59cda/IMG_0591.webp 28w,\n/static/ceb49c3c631485453e71e00d7f84b069/7da75/IMG_0591.webp 55w,\n/static/ceb49c3c631485453e71e00d7f84b069/8678c/IMG_0591.webp 110w,\n/static/ceb49c3c631485453e71e00d7f84b069/f282e/IMG_0591.webp 165w,\n/static/ceb49c3c631485453e71e00d7f84b069/a7b21/IMG_0591.webp 220w,\n/static/ceb49c3c631485453e71e00d7f84b069/63099/IMG_0591.webp 1182w","sizes":"(max-width: 110px) 100vw, 110px"}}}},"primary_tag":{"slug":"reviews","url":"https://backend.shahednasser.com/tag/reviews/","name":"Reviews","visibility":"public","feature_image":"https://backend.shahednasser.com/content/images/2022/01/pexels-jess-bailey-designs-2647794--1--2.jpg","description":"Reviews for some services, products, or companies. If interested in having your product or service reviewed, please check out the \"collaborate\" page.","meta_title":null,"meta_description":null,"featureImageSharp":{"base":"pexels-jess-bailey-designs-2647794--1--2.jpg","publicURL":"/static/9dbdb73d894862ceac3b9ca3d26610aa/pexels-jess-bailey-designs-2647794--1--2.jpg","imageMeta":{"width":3456,"height":4608},"childImageSharp":{"fluid":{"base64":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAbABQDASIAAhEBAxEB/8QAGAAAAwEBAAAAAAAAAAAAAAAAAAEDAgX/xAAVAQEBAAAAAAAAAAAAAAAAAAAAAf/aAAwDAQACEAMQAAAB7zy0ACNJ1GYD/8QAGRAAAgMBAAAAAAAAAAAAAAAAAhABAxEg/9oACAEBAAEFAnuMaxjr/8QAFBEBAAAAAAAAAAAAAAAAAAAAIP/aAAgBAwEBPwEf/8QAFBEBAAAAAAAAAAAAAAAAAAAAIP/aAAgBAgEBPwEf/8QAGRAAAgMBAAAAAAAAAAAAAAAAARARITFR/9oACAEBAAY/AnbnT0sP/8QAGhABAAIDAQAAAAAAAAAAAAAAARARACFxUf/aAAgBAQABPyGUG0HZRtfoXhvcLfc//9oADAMBAAIAAwAAABCf5s7/xAAVEQEBAAAAAAAAAAAAAAAAAAAREP/aAAgBAwEBPxAiz//EABURAQEAAAAAAAAAAAAAAAAAABAR/9oACAECAQE/ECQ//8QAHhABAAICAgMBAAAAAAAAAAAAAQARECFBUTFhocH/2gAIAQEAAT8QMVK4XtVBEsxoUO0++I1cTg/ZcQFdLfvV4Vuf/9k=","aspectRatio":0.7492795389048992,"src":"/static/9dbdb73d894862ceac3b9ca3d26610aa/d5c54/pexels-jess-bailey-designs-2647794--1--2.jpg","srcSet":"/static/9dbdb73d894862ceac3b9ca3d26610aa/65d8c/pexels-jess-bailey-designs-2647794--1--2.jpg 260w,\n/static/9dbdb73d894862ceac3b9ca3d26610aa/c5f21/pexels-jess-bailey-designs-2647794--1--2.jpg 520w,\n/static/9dbdb73d894862ceac3b9ca3d26610aa/d5c54/pexels-jess-bailey-designs-2647794--1--2.jpg 1040w,\n/static/9dbdb73d894862ceac3b9ca3d26610aa/81a53/pexels-jess-bailey-designs-2647794--1--2.jpg 1560w,\n/static/9dbdb73d894862ceac3b9ca3d26610aa/f734f/pexels-jess-bailey-designs-2647794--1--2.jpg 2080w,\n/static/9dbdb73d894862ceac3b9ca3d26610aa/f2665/pexels-jess-bailey-designs-2647794--1--2.jpg 3456w","srcWebp":"/static/9dbdb73d894862ceac3b9ca3d26610aa/e4875/pexels-jess-bailey-designs-2647794--1--2.webp","srcSetWebp":"/static/9dbdb73d894862ceac3b9ca3d26610aa/dc8f3/pexels-jess-bailey-designs-2647794--1--2.webp 260w,\n/static/9dbdb73d894862ceac3b9ca3d26610aa/2db4b/pexels-jess-bailey-designs-2647794--1--2.webp 520w,\n/static/9dbdb73d894862ceac3b9ca3d26610aa/e4875/pexels-jess-bailey-designs-2647794--1--2.webp 1040w,\n/static/9dbdb73d894862ceac3b9ca3d26610aa/f5845/pexels-jess-bailey-designs-2647794--1--2.webp 1560w,\n/static/9dbdb73d894862ceac3b9ca3d26610aa/ecdd3/pexels-jess-bailey-designs-2647794--1--2.webp 2080w,\n/static/9dbdb73d894862ceac3b9ca3d26610aa/63d3e/pexels-jess-bailey-designs-2647794--1--2.webp 3456w","sizes":"(max-width: 1040px) 100vw, 1040px"}}}},"tags":[{"slug":"reviews","url":"https://backend.shahednasser.com/tag/reviews/","name":"Reviews","visibility":"public","feature_image":"https://backend.shahednasser.com/content/images/2022/01/pexels-jess-bailey-designs-2647794--1--2.jpg","description":"Reviews for some services, products, or companies. If interested in having your product or service reviewed, please check out the \"collaborate\" page.","meta_title":null,"meta_description":null,"featureImageSharp":null},{"slug":"ecommerce","url":"https://backend.shahednasser.com/tag/ecommerce/","name":"eCommerce","visibility":"public","feature_image":null,"description":"Learn more about eCommerce through tutorials, articles, and tips.","meta_title":null,"meta_description":null,"featureImageSharp":null},{"slug":"js","url":"https://backend.shahednasser.com/tag/js/","name":"Javascript","visibility":"public","feature_image":"https://backend.shahednasser.com/content/images/2022/01/photo-1592609931095-54a2168ae893-2.jpeg","description":"Learn more about Javascript through tutorials, articles, and tips.","meta_title":null,"meta_description":"Learn more about Javascript through tutorials, articles and tips.","featureImageSharp":null}],"plaintext":"E-commerce platforms and frameworks are usually built on a complex architecture\nto provide you with the best features as a developer and as a business owner. \n\nAlthough this is good as they pack all useful features in one framework in the\nhopes no additional work needs to be done to launch a store, this can result in\nsome issues. The store can be slow which would require a set of external tools\nto make it faster and in some cases big hosting plans to ensure the customers\nget the best experience.\n\nIn addition to that, customizing an e-commerce store to fit your or your\nclient's needs using some platforms can be hard due to their tightly bound or\ncomplicated architecture.\n\nThis is where Medusa [https://www.medusajs.com/] comes in. Medusa is an\nopen-source headless commerce platform that aims to simplify how e-commerce\nplatforms are built and provide you with the highest level of customization you\ncan attain to build the e-commerce store you have in mind.\n\nIn this article, we'll briefly take a look at Medusa's structure and what it\nprovides, then we'll see what are some of its strong points and what are some of\nits cons that you should keep in mind before choosing Medusa.\n\nMedusa's Architecture \nMedusa as a full e-commerce system is split into 3 parts or 3 building blocks.\n\nThe core of Medusa is its backend [https://github.com/medusajs/medusa/]. The\nbackend exposes a REST API and connects directly to the database. The backend\nacts as the headless commerce, accessing and managing the store's data. The\nbackend is built with Node.js and express. By default and for development\npurposes it provides support for SQLite for the database, however, it also\nprovides support for PostgreSQL and Redis.\n\nNext comes the storefront. Medusa provides 2 storefronts that you can use, one\nbuilt with Next.js [https://github.com/medusajs/nextjs-starter-medusa] and\nanother with Gatsby.js [https://github.com/medusajs/gatsby-starter-medusa]. The\nstorefront connects to the backend and provides a slick design and a fast\nexperience for your users.\n\nThe last building block is the admin dashboard\n[https://github.com/medusajs/admin]. The admin dashboard connects to the backend\nand allows you to easily manage products, orders, customers, and settings.\n\nThe only building block required to use Medusa is the backend. With the backend,\nyou are able to customize your storefront as you see fit. Although Medusa\nprovides a storefront that you can use, you are not obligated to use it and can\ncreate your own. The same goes for the admin dashboard.\n\nE-Commerce Features\nIn this section, we'll cover some of the e-commerce features that Medusa\nprovides. These are the features that you should expect when you create a store\nwith Medusa.\n\nProduct Variants\nIn Medusa, you can easily add product variants like Size. You can also add\nmultiple prices for different currencies, manage the inventory of each variant,\nand more.\n\nDiscounts\nYou can add discounts or offer free shipping based on region. You can apply the\ndiscount as a percentage or as a fixed amount.\n\nGift Cards\nGift cards come built-in in Medusa. You can set an image for the gift card,\nmanage how much the gift card is worth and add different worths for a gift card,\nand more.\n\nMultiple Currencies\nIn Medusa, you can choose multiple currencies for your store and set a default\none.\n\nMultiple Regions\nMedusa allows you to add multiple regions, each having its own countries that\nare part of the region, payment method, shipping method, currency, and more.\n\nMedusa's Strong Points\nBlazingly Fast\nAs the frontend is decoupled from the backend, it removes the extra workload\nthat is usually done in tightly coupled systems.\n\nIn addition, static site generators like Gatsby can be used to generate the\nstorefront which would only need to connect to the backend through the REST\nAPIs.\n\nHighly Customizable\nThe decoupling of the frontend from the backend allows you to customize your\nstorefront freely. You can pick whatever programming language or framework you\nwish to use for the front end.\n\nThat's one of the benefits of headless commerce. You are free to focus on the\nfront end and get creative with it without the shackles of the backend.\n\nEasy Development\nOne of the cons of a lot of popular e-commerce platforms is that they get too\ncomplicated or hard to learn. So, although they provide a lot of features that\nare enough to launch a store as is if you need to do any custom development you\nmight need a lot of time to learn or understand its architecture.\n\nMedusa is easy to use. In addition to the REST APIs available by default, you\ncan easily add your own APIs. You can also create plugins to add missing\nfunctionalities or integrations that you need for your store.\n\nEasy Setup and Deployment\nYou can set up a medusa store locally in a matter of minutes. With just 3\ncommands at most, you can have the backend, frontend, and admin dashboard all\ninstalled and ready to use.\n\nSimilarly, its deployment is easy as well. Medusa's documentation already has a\nguide on how to deploy the backend on Heruko\n[https://docs.medusa-commerce.com/how-to/deploying-on-heroku], and the admin\ndashboard on Netlify\n[https://docs.medusa-commerce.com/how-to/deploying-admin-on-netlify].\n\nMedusa's Cons\nNo Internationalization\nAt the moment of writing this, Medusa does not support multiple languages.\nInternationalization is a very important aspect of e-commerce.\n\nSo, if your store needs to support languages other than the English language,\nthen Medusa is not a good option.\n\nMedusa's roadmap [https://roadmap.medusa-commerce.com/c/8-localizations-api] \nshows that Localization is a planned task. So, in the future, it should be\navailable.\n\nLack of Community Plugins\nAs Medusa is relatively new, at the moment there aren't many plugins created by\nthe community to add custom functionalities to a Medusa store.\n\nThis is especially essential when it comes to payment and shipment integrations.\nMedusa comes with support for Stripe by default. Any additional payment or\nshipment services integration needs to be developed by you.\n\nSimple Storefront\nAlthough we all love simplicity, the storefronts that Medusa currently provides\nare too simple. For example, although you can add multiple regions or currencies\nin the admin panel, there's no way to actually switch between them when using\nthe storefronts Medusa provides.\n\nThis won't be a problem if you're mostly relying on Medusa's headless commerce\nbackend, or you're looking to customize your frontend as necessary for you.\nHowever, if you need to use the frontend as is with additional development, then\nyou need to consider this first.\n\nWhen Should You Use Medusa\nMedusa is the perfect option if you are looking for headless commerce. With its\neasy setup, you can have a headless commerce backend ready in a few minutes.\n\nMedusa is also perfect if you're looking for complete freedom when designing\nyour storefront. Even if you use one of its storefronts, you can easily make\nchanges to the design as you find fitting.\n\nMedusa is also one of the very few options available to build e-commerce stores\nwith modern technologies.\n\nConclusion\nMedusa is still an evolving e-commerce platform. Yet, it still offers promising\nresults compared to a lot of other e-commerce platforms when it comes to\nperformance, customization, and other pros we've discussed throughout the\narticle.\n\nYou can get started with Medusa in minutes with their Quickstart documentation.\n[https://docs.medusa-commerce.com/quickstart/quick-start]","html":"<p>E-commerce platforms and frameworks are usually built on a complex architecture to provide you with the best features as a developer and as a business owner. </p><p>Although this is good as they pack all useful features in one framework in the hopes no additional work needs to be done to launch a store, this can result in some issues. The store can be slow which would require a set of external tools to make it faster and in some cases big hosting plans to ensure the customers get the best experience.</p><p>In addition to that, customizing an e-commerce store to fit your or your client's needs using some platforms can be hard due to their tightly bound or complicated architecture.</p><p>This is where <a href=\"https://www.medusajs.com/\">Medusa</a> comes in. Medusa is an open-source headless commerce platform that aims to simplify how e-commerce platforms are built and provide you with the highest level of customization you can attain to build the e-commerce store you have in mind.</p><p>In this article, we'll briefly take a look at Medusa's structure and what it provides, then we'll see what are some of its strong points and what are some of its cons that you should keep in mind before choosing Medusa.</p><h2 id=\"medusas-architecture\">Medusa's Architecture </h2><p>Medusa as a full e-commerce system is split into 3 parts or 3 building blocks.</p><p>The core of Medusa is its <a href=\"https://github.com/medusajs/medusa/\">backend</a>. The backend exposes a REST API and connects directly to the database. The backend acts as the headless commerce, accessing and managing the store's data. The backend is built with Node.js and express. By default and for development purposes it provides support for SQLite for the database, however, it also provides support for PostgreSQL and Redis.</p><p>Next comes the storefront. Medusa provides 2 storefronts that you can use, one built with <a href=\"https://github.com/medusajs/nextjs-starter-medusa\">Next.js</a> and another with <a href=\"https://github.com/medusajs/gatsby-starter-medusa\">Gatsby.js</a>. The storefront connects to the backend and provides a slick design and a fast experience for your users.</p><p>The last building block is the <a href=\"https://github.com/medusajs/admin\">admin dashboard</a>. The admin dashboard connects to the backend and allows you to easily manage products, orders, customers, and settings.</p><p>The only building block required to use Medusa is the backend. With the backend, you are able to customize your storefront as you see fit. Although Medusa provides a storefront that you can use, you are not obligated to use it and can create your own. The same goes for the admin dashboard.</p><h2 id=\"e-commerce-features\">E-Commerce Features</h2><p>In this section, we'll cover some of the e-commerce features that Medusa provides. These are the features that you should expect when you create a store with Medusa.</p><h3 id=\"product-variants\">Product Variants</h3><p>In Medusa, you can easily add product variants like Size. You can also add multiple prices for different currencies, manage the inventory of each variant, and more.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-12.55.08-AM.png\" class=\"kg-image\" alt loading=\"lazy\" width=\"2000\" height=\"743\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/10/Screen-Shot-2021-10-10-at-12.55.08-AM.png 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/10/Screen-Shot-2021-10-10-at-12.55.08-AM.png 1000w, https://backend.shahednasser.com/content/images/size/w1600/2021/10/Screen-Shot-2021-10-10-at-12.55.08-AM.png 1600w, https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-12.55.08-AM.png 2078w\" sizes=\"(min-width: 720px) 720px\"></figure><h3 id=\"discounts\">Discounts</h3><p>You can add discounts or offer free shipping based on region. You can apply the discount as a percentage or as a fixed amount.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-12.56.30-AM.png\" class=\"kg-image\" alt loading=\"lazy\" width=\"1446\" height=\"1568\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/10/Screen-Shot-2021-10-10-at-12.56.30-AM.png 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/10/Screen-Shot-2021-10-10-at-12.56.30-AM.png 1000w, https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-12.56.30-AM.png 1446w\" sizes=\"(min-width: 720px) 720px\"></figure><h3 id=\"gift-cards\">Gift Cards</h3><p>Gift cards come built-in in Medusa. You can set an image for the gift card, manage how much the gift card is worth and add different worths for a gift card, and more.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-12.57.52-AM.png\" class=\"kg-image\" alt loading=\"lazy\" width=\"1478\" height=\"1530\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/10/Screen-Shot-2021-10-10-at-12.57.52-AM.png 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/10/Screen-Shot-2021-10-10-at-12.57.52-AM.png 1000w, https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-12.57.52-AM.png 1478w\" sizes=\"(min-width: 720px) 720px\"></figure><h3 id=\"multiple-currencies\">Multiple Currencies</h3><p>In Medusa, you can choose multiple currencies for your store and set a default one.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-1.00.21-AM.png\" class=\"kg-image\" alt loading=\"lazy\" width=\"802\" height=\"650\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/10/Screen-Shot-2021-10-10-at-1.00.21-AM.png 600w, https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-1.00.21-AM.png 802w\" sizes=\"(min-width: 720px) 720px\"></figure><h3 id=\"multiple-regions\">Multiple Regions</h3><p>Medusa allows you to add multiple regions, each having its own countries that are part of the region, payment method, shipping method, currency, and more.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-1.00.43-AM.png\" class=\"kg-image\" alt loading=\"lazy\" width=\"2000\" height=\"459\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/10/Screen-Shot-2021-10-10-at-1.00.43-AM.png 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/10/Screen-Shot-2021-10-10-at-1.00.43-AM.png 1000w, https://backend.shahednasser.com/content/images/size/w1600/2021/10/Screen-Shot-2021-10-10-at-1.00.43-AM.png 1600w, https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-1.00.43-AM.png 2146w\" sizes=\"(min-width: 720px) 720px\"></figure><h2 id=\"medusas-strong-points\">Medusa's Strong Points</h2><h3 id=\"blazingly-fast\">Blazingly Fast</h3><p>As the frontend is decoupled from the backend, it removes the extra workload that is usually done in tightly coupled systems.</p><p>In addition, static site generators like Gatsby can be used to generate the storefront which would only need to connect to the backend through the REST APIs.</p><h3 id=\"highly-customizable\">Highly Customizable</h3><p>The decoupling of the frontend from the backend allows you to customize your storefront freely. You can pick whatever programming language or framework you wish to use for the front end.</p><p>That's one of the benefits of headless commerce. You are free to focus on the front end and get creative with it without the shackles of the backend.</p><h3 id=\"easy-development\">Easy Development</h3><p>One of the cons of a lot of popular e-commerce platforms is that they get too complicated or hard to learn. So, although they provide a lot of features that are enough to launch a store as is if you need to do any custom development you might need a lot of time to learn or understand its architecture.</p><p>Medusa is easy to use. In addition to the REST APIs available by default, you can easily add your own APIs. You can also create plugins to add missing functionalities or integrations that you need for your store.</p><h3 id=\"easy-setup-and-deployment\">Easy Setup and Deployment</h3><p>You can set up a medusa store locally in a matter of minutes. With just 3 commands at most, you can have the backend, frontend, and admin dashboard all installed and ready to use.</p><p>Similarly, its deployment is easy as well. Medusa's documentation already has a guide on how to <a href=\"https://docs.medusa-commerce.com/how-to/deploying-on-heroku\">deploy the backend on Heruko</a>, and the <a href=\"https://docs.medusa-commerce.com/how-to/deploying-admin-on-netlify\">admin dashboard on Netlify</a>.</p><h2 id=\"medusas-cons\">Medusa's Cons</h2><h3 id=\"no-internationalization\">No Internationalization</h3><p>At the moment of writing this, Medusa does not support multiple languages. Internationalization is a very important aspect of e-commerce.</p><p>So, if your store needs to support languages other than the English language, then Medusa is not a good option.</p><p>Medusa's <a href=\"https://roadmap.medusa-commerce.com/c/8-localizations-api\">roadmap</a> shows that Localization is a planned task. So, in the future, it should be available.</p><h3 id=\"lack-of-community-plugins\">Lack of Community Plugins</h3><p>As Medusa is relatively new, at the moment there aren't many plugins created by the community to add custom functionalities to a Medusa store.</p><p>This is especially essential when it comes to payment and shipment integrations. Medusa comes with support for Stripe by default. Any additional payment or shipment services integration needs to be developed by you.</p><h3 id=\"simple-storefront\">Simple Storefront</h3><p>Although we all love simplicity, the storefronts that Medusa currently provides are too simple. For example, although you can add multiple regions or currencies in the admin panel, there's no way to actually switch between them when using the storefronts Medusa provides.</p><p>This won't be a problem if you're mostly relying on Medusa's headless commerce backend, or you're looking to customize your frontend as necessary for you. However, if you need to use the frontend as is with additional development, then you need to consider this first.</p><h2 id=\"when-should-you-use-medusa\">When Should You Use Medusa</h2><p>Medusa is the perfect option if you are looking for headless commerce. With its easy setup, you can have a headless commerce backend ready in a few minutes.</p><p>Medusa is also perfect if you're looking for complete freedom when designing your storefront. Even if you use one of its storefronts, you can easily make changes to the design as you find fitting.</p><p>Medusa is also one of the very few options available to build e-commerce stores with modern technologies.</p><h2 id=\"conclusion\">Conclusion</h2><p>Medusa is still an evolving e-commerce platform. Yet, it still offers promising results compared to a lot of other e-commerce platforms when it comes to performance, customization, and other pros we've discussed throughout the article.</p><p>You can get started with Medusa in minutes with their <a href=\"https://docs.medusa-commerce.com/quickstart/quick-start\">Quickstart documentation.</a></p>","url":"https://backend.shahednasser.com/medusa-create-fast-and-highly-customizable-ecommerce-store/","canonical_url":null,"uuid":"75297ccf-dbca-4b55-a097-de6949756328","codeinjection_foot":null,"codeinjection_head":null,"codeinjection_styles":null,"comment_id":"6161d15b3eea8f060129b2fc","reading_time":5,"send_email_when_published":null,"email_subject":null,"childHtmlRehype":{"html":"<p>E-commerce platforms and frameworks are usually built on a complex architecture to provide you with the best features as a developer and as a business owner. </p><p>Although this is good as they pack all useful features in one framework in the hopes no additional work needs to be done to launch a store, this can result in some issues. The store can be slow which would require a set of external tools to make it faster and in some cases big hosting plans to ensure the customers get the best experience.</p><p>In addition to that, customizing an e-commerce store to fit your or your client's needs using some platforms can be hard due to their tightly bound or complicated architecture.</p><p>This is where <a href=\"https://www.medusajs.com/\">Medusa</a> comes in. Medusa is an open-source headless commerce platform that aims to simplify how e-commerce platforms are built and provide you with the highest level of customization you can attain to build the e-commerce store you have in mind.</p><p>In this article, we'll briefly take a look at Medusa's structure and what it provides, then we'll see what are some of its strong points and what are some of its cons that you should keep in mind before choosing Medusa.</p><h2 id=\"medusas-architecture\">Medusa's Architecture </h2><p>Medusa as a full e-commerce system is split into 3 parts or 3 building blocks.</p><p>The core of Medusa is its <a href=\"https://github.com/medusajs/medusa/\">backend</a>. The backend exposes a REST API and connects directly to the database. The backend acts as the headless commerce, accessing and managing the store's data. The backend is built with Node.js and express. By default and for development purposes it provides support for SQLite for the database, however, it also provides support for PostgreSQL and Redis.</p><p>Next comes the storefront. Medusa provides 2 storefronts that you can use, one built with <a href=\"https://github.com/medusajs/nextjs-starter-medusa\">Next.js</a> and another with <a href=\"https://github.com/medusajs/gatsby-starter-medusa\">Gatsby.js</a>. The storefront connects to the backend and provides a slick design and a fast experience for your users.</p><p>The last building block is the <a href=\"https://github.com/medusajs/admin\">admin dashboard</a>. The admin dashboard connects to the backend and allows you to easily manage products, orders, customers, and settings.</p><p>The only building block required to use Medusa is the backend. With the backend, you are able to customize your storefront as you see fit. Although Medusa provides a storefront that you can use, you are not obligated to use it and can create your own. The same goes for the admin dashboard.</p><h2 id=\"e-commerce-features\">E-Commerce Features</h2><p>In this section, we'll cover some of the e-commerce features that Medusa provides. These are the features that you should expect when you create a store with Medusa.</p><h3 id=\"product-variants\">Product Variants</h3><p>In Medusa, you can easily add product variants like Size. You can also add multiple prices for different currencies, manage the inventory of each variant, and more.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-12.55.08-AM.png\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"2000\" height=\"743\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/10/Screen-Shot-2021-10-10-at-12.55.08-AM.png 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/10/Screen-Shot-2021-10-10-at-12.55.08-AM.png 1000w, https://backend.shahednasser.com/content/images/size/w1600/2021/10/Screen-Shot-2021-10-10-at-12.55.08-AM.png 1600w, https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-12.55.08-AM.png 2078w\" sizes=\"(min-width: 720px) 720px\"></figure><h3 id=\"discounts\">Discounts</h3><p>You can add discounts or offer free shipping based on region. You can apply the discount as a percentage or as a fixed amount.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-12.56.30-AM.png\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"1446\" height=\"1568\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/10/Screen-Shot-2021-10-10-at-12.56.30-AM.png 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/10/Screen-Shot-2021-10-10-at-12.56.30-AM.png 1000w, https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-12.56.30-AM.png 1446w\" sizes=\"(min-width: 720px) 720px\"></figure><h3 id=\"gift-cards\">Gift Cards</h3><p>Gift cards come built-in in Medusa. You can set an image for the gift card, manage how much the gift card is worth and add different worths for a gift card, and more.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-12.57.52-AM.png\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"1478\" height=\"1530\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/10/Screen-Shot-2021-10-10-at-12.57.52-AM.png 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/10/Screen-Shot-2021-10-10-at-12.57.52-AM.png 1000w, https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-12.57.52-AM.png 1478w\" sizes=\"(min-width: 720px) 720px\"></figure><h3 id=\"multiple-currencies\">Multiple Currencies</h3><p>In Medusa, you can choose multiple currencies for your store and set a default one.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-1.00.21-AM.png\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"802\" height=\"650\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/10/Screen-Shot-2021-10-10-at-1.00.21-AM.png 600w, https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-1.00.21-AM.png 802w\" sizes=\"(min-width: 720px) 720px\"></figure><h3 id=\"multiple-regions\">Multiple Regions</h3><p>Medusa allows you to add multiple regions, each having its own countries that are part of the region, payment method, shipping method, currency, and more.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-1.00.43-AM.png\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"2000\" height=\"459\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/10/Screen-Shot-2021-10-10-at-1.00.43-AM.png 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/10/Screen-Shot-2021-10-10-at-1.00.43-AM.png 1000w, https://backend.shahednasser.com/content/images/size/w1600/2021/10/Screen-Shot-2021-10-10-at-1.00.43-AM.png 1600w, https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-1.00.43-AM.png 2146w\" sizes=\"(min-width: 720px) 720px\"></figure><h2 id=\"medusas-strong-points\">Medusa's Strong Points</h2><h3 id=\"blazingly-fast\">Blazingly Fast</h3><p>As the frontend is decoupled from the backend, it removes the extra workload that is usually done in tightly coupled systems.</p><p>In addition, static site generators like Gatsby can be used to generate the storefront which would only need to connect to the backend through the REST APIs.</p><h3 id=\"highly-customizable\">Highly Customizable</h3><p>The decoupling of the frontend from the backend allows you to customize your storefront freely. You can pick whatever programming language or framework you wish to use for the front end.</p><p>That's one of the benefits of headless commerce. You are free to focus on the front end and get creative with it without the shackles of the backend.</p><h3 id=\"easy-development\">Easy Development</h3><p>One of the cons of a lot of popular e-commerce platforms is that they get too complicated or hard to learn. So, although they provide a lot of features that are enough to launch a store as is if you need to do any custom development you might need a lot of time to learn or understand its architecture.</p><p>Medusa is easy to use. In addition to the REST APIs available by default, you can easily add your own APIs. You can also create plugins to add missing functionalities or integrations that you need for your store.</p><h3 id=\"easy-setup-and-deployment\">Easy Setup and Deployment</h3><p>You can set up a medusa store locally in a matter of minutes. With just 3 commands at most, you can have the backend, frontend, and admin dashboard all installed and ready to use.</p><p>Similarly, its deployment is easy as well. Medusa's documentation already has a guide on how to <a href=\"https://docs.medusa-commerce.com/how-to/deploying-on-heroku\">deploy the backend on Heruko</a>, and the <a href=\"https://docs.medusa-commerce.com/how-to/deploying-admin-on-netlify\">admin dashboard on Netlify</a>.</p><h2 id=\"medusas-cons\">Medusa's Cons</h2><h3 id=\"no-internationalization\">No Internationalization</h3><p>At the moment of writing this, Medusa does not support multiple languages. Internationalization is a very important aspect of e-commerce.</p><p>So, if your store needs to support languages other than the English language, then Medusa is not a good option.</p><p>Medusa's <a href=\"https://roadmap.medusa-commerce.com/c/8-localizations-api\">roadmap</a> shows that Localization is a planned task. So, in the future, it should be available.</p><h3 id=\"lack-of-community-plugins\">Lack of Community Plugins</h3><p>As Medusa is relatively new, at the moment there aren't many plugins created by the community to add custom functionalities to a Medusa store.</p><p>This is especially essential when it comes to payment and shipment integrations. Medusa comes with support for Stripe by default. Any additional payment or shipment services integration needs to be developed by you.</p><h3 id=\"simple-storefront\">Simple Storefront</h3><p>Although we all love simplicity, the storefronts that Medusa currently provides are too simple. For example, although you can add multiple regions or currencies in the admin panel, there's no way to actually switch between them when using the storefronts Medusa provides.</p><p>This won't be a problem if you're mostly relying on Medusa's headless commerce backend, or you're looking to customize your frontend as necessary for you. However, if you need to use the frontend as is with additional development, then you need to consider this first.</p><h2 id=\"when-should-you-use-medusa\">When Should You Use Medusa</h2><p>Medusa is the perfect option if you are looking for headless commerce. With its easy setup, you can have a headless commerce backend ready in a few minutes.</p><p>Medusa is also perfect if you're looking for complete freedom when designing your storefront. Even if you use one of its storefronts, you can easily make changes to the design as you find fitting.</p><p>Medusa is also one of the very few options available to build e-commerce stores with modern technologies.</p><h2 id=\"conclusion\">Conclusion</h2><p>Medusa is still an evolving e-commerce platform. Yet, it still offers promising results compared to a lot of other e-commerce platforms when it comes to performance, customization, and other pros we've discussed throughout the article.</p><p>You can get started with Medusa in minutes with their <a href=\"https://docs.medusa-commerce.com/quickstart/quick-start\">Quickstart documentation.</a></p>","htmlAst":{"type":"root","children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"E-commerce platforms and frameworks are usually built on a complex architecture to provide you with the best features as a developer and as a business owner. "}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Although this is good as they pack all useful features in one framework in the hopes no additional work needs to be done to launch a store, this can result in some issues. The store can be slow which would require a set of external tools to make it faster and in some cases big hosting plans to ensure the customers get the best experience."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In addition to that, customizing an e-commerce store to fit your or your client's needs using some platforms can be hard due to their tightly bound or complicated architecture."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This is where "},{"type":"element","tagName":"a","properties":{"href":"https://www.medusajs.com/"},"children":[{"type":"text","value":"Medusa"}]},{"type":"text","value":" comes in. Medusa is an open-source headless commerce platform that aims to simplify how e-commerce platforms are built and provide you with the highest level of customization you can attain to build the e-commerce store you have in mind."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In this article, we'll briefly take a look at Medusa's structure and what it provides, then we'll see what are some of its strong points and what are some of its cons that you should keep in mind before choosing Medusa."}]},{"type":"element","tagName":"h2","properties":{"id":"medusas-architecture"},"children":[{"type":"text","value":"Medusa's Architecture "}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Medusa as a full e-commerce system is split into 3 parts or 3 building blocks."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The core of Medusa is its "},{"type":"element","tagName":"a","properties":{"href":"https://github.com/medusajs/medusa/"},"children":[{"type":"text","value":"backend"}]},{"type":"text","value":". The backend exposes a REST API and connects directly to the database. The backend acts as the headless commerce, accessing and managing the store's data. The backend is built with Node.js and express. By default and for development purposes it provides support for SQLite for the database, however, it also provides support for PostgreSQL and Redis."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Next comes the storefront. Medusa provides 2 storefronts that you can use, one built with "},{"type":"element","tagName":"a","properties":{"href":"https://github.com/medusajs/nextjs-starter-medusa"},"children":[{"type":"text","value":"Next.js"}]},{"type":"text","value":" and another with "},{"type":"element","tagName":"a","properties":{"href":"https://github.com/medusajs/gatsby-starter-medusa"},"children":[{"type":"text","value":"Gatsby.js"}]},{"type":"text","value":". The storefront connects to the backend and provides a slick design and a fast experience for your users."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The last building block is the "},{"type":"element","tagName":"a","properties":{"href":"https://github.com/medusajs/admin"},"children":[{"type":"text","value":"admin dashboard"}]},{"type":"text","value":". The admin dashboard connects to the backend and allows you to easily manage products, orders, customers, and settings."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The only building block required to use Medusa is the backend. With the backend, you are able to customize your storefront as you see fit. Although Medusa provides a storefront that you can use, you are not obligated to use it and can create your own. The same goes for the admin dashboard."}]},{"type":"element","tagName":"h2","properties":{"id":"e-commerce-features"},"children":[{"type":"text","value":"E-Commerce Features"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In this section, we'll cover some of the e-commerce features that Medusa provides. These are the features that you should expect when you create a store with Medusa."}]},{"type":"element","tagName":"h3","properties":{"id":"product-variants"},"children":[{"type":"text","value":"Product Variants"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In Medusa, you can easily add product variants like Size. You can also add multiple prices for different currencies, manage the inventory of each variant, and more."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-12.55.08-AM.png","className":["kg-image"],"alt":"","loading":"lazy","width":2000,"height":743,"srcSet":["https://backend.shahednasser.com/content/images/size/w600/2021/10/Screen-Shot-2021-10-10-at-12.55.08-AM.png 600w","https://backend.shahednasser.com/content/images/size/w1000/2021/10/Screen-Shot-2021-10-10-at-12.55.08-AM.png 1000w","https://backend.shahednasser.com/content/images/size/w1600/2021/10/Screen-Shot-2021-10-10-at-12.55.08-AM.png 1600w","https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-12.55.08-AM.png 2078w"],"sizes":"(min-width: 720px) 720px"},"children":[]}]},{"type":"element","tagName":"h3","properties":{"id":"discounts"},"children":[{"type":"text","value":"Discounts"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can add discounts or offer free shipping based on region. You can apply the discount as a percentage or as a fixed amount."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-12.56.30-AM.png","className":["kg-image"],"alt":"","loading":"lazy","width":1446,"height":1568,"srcSet":["https://backend.shahednasser.com/content/images/size/w600/2021/10/Screen-Shot-2021-10-10-at-12.56.30-AM.png 600w","https://backend.shahednasser.com/content/images/size/w1000/2021/10/Screen-Shot-2021-10-10-at-12.56.30-AM.png 1000w","https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-12.56.30-AM.png 1446w"],"sizes":"(min-width: 720px) 720px"},"children":[]}]},{"type":"element","tagName":"h3","properties":{"id":"gift-cards"},"children":[{"type":"text","value":"Gift Cards"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Gift cards come built-in in Medusa. You can set an image for the gift card, manage how much the gift card is worth and add different worths for a gift card, and more."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-12.57.52-AM.png","className":["kg-image"],"alt":"","loading":"lazy","width":1478,"height":1530,"srcSet":["https://backend.shahednasser.com/content/images/size/w600/2021/10/Screen-Shot-2021-10-10-at-12.57.52-AM.png 600w","https://backend.shahednasser.com/content/images/size/w1000/2021/10/Screen-Shot-2021-10-10-at-12.57.52-AM.png 1000w","https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-12.57.52-AM.png 1478w"],"sizes":"(min-width: 720px) 720px"},"children":[]}]},{"type":"element","tagName":"h3","properties":{"id":"multiple-currencies"},"children":[{"type":"text","value":"Multiple Currencies"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In Medusa, you can choose multiple currencies for your store and set a default one."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-1.00.21-AM.png","className":["kg-image"],"alt":"","loading":"lazy","width":802,"height":650,"srcSet":["https://backend.shahednasser.com/content/images/size/w600/2021/10/Screen-Shot-2021-10-10-at-1.00.21-AM.png 600w","https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-1.00.21-AM.png 802w"],"sizes":"(min-width: 720px) 720px"},"children":[]}]},{"type":"element","tagName":"h3","properties":{"id":"multiple-regions"},"children":[{"type":"text","value":"Multiple Regions"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Medusa allows you to add multiple regions, each having its own countries that are part of the region, payment method, shipping method, currency, and more."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-1.00.43-AM.png","className":["kg-image"],"alt":"","loading":"lazy","width":2000,"height":459,"srcSet":["https://backend.shahednasser.com/content/images/size/w600/2021/10/Screen-Shot-2021-10-10-at-1.00.43-AM.png 600w","https://backend.shahednasser.com/content/images/size/w1000/2021/10/Screen-Shot-2021-10-10-at-1.00.43-AM.png 1000w","https://backend.shahednasser.com/content/images/size/w1600/2021/10/Screen-Shot-2021-10-10-at-1.00.43-AM.png 1600w","https://backend.shahednasser.com/content/images/2021/10/Screen-Shot-2021-10-10-at-1.00.43-AM.png 2146w"],"sizes":"(min-width: 720px) 720px"},"children":[]}]},{"type":"element","tagName":"h2","properties":{"id":"medusas-strong-points"},"children":[{"type":"text","value":"Medusa's Strong Points"}]},{"type":"element","tagName":"h3","properties":{"id":"blazingly-fast"},"children":[{"type":"text","value":"Blazingly Fast"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"As the frontend is decoupled from the backend, it removes the extra workload that is usually done in tightly coupled systems."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In addition, static site generators like Gatsby can be used to generate the storefront which would only need to connect to the backend through the REST APIs."}]},{"type":"element","tagName":"h3","properties":{"id":"highly-customizable"},"children":[{"type":"text","value":"Highly Customizable"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The decoupling of the frontend from the backend allows you to customize your storefront freely. You can pick whatever programming language or framework you wish to use for the front end."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"That's one of the benefits of headless commerce. You are free to focus on the front end and get creative with it without the shackles of the backend."}]},{"type":"element","tagName":"h3","properties":{"id":"easy-development"},"children":[{"type":"text","value":"Easy Development"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"One of the cons of a lot of popular e-commerce platforms is that they get too complicated or hard to learn. So, although they provide a lot of features that are enough to launch a store as is if you need to do any custom development you might need a lot of time to learn or understand its architecture."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Medusa is easy to use. In addition to the REST APIs available by default, you can easily add your own APIs. You can also create plugins to add missing functionalities or integrations that you need for your store."}]},{"type":"element","tagName":"h3","properties":{"id":"easy-setup-and-deployment"},"children":[{"type":"text","value":"Easy Setup and Deployment"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can set up a medusa store locally in a matter of minutes. With just 3 commands at most, you can have the backend, frontend, and admin dashboard all installed and ready to use."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Similarly, its deployment is easy as well. Medusa's documentation already has a guide on how to "},{"type":"element","tagName":"a","properties":{"href":"https://docs.medusa-commerce.com/how-to/deploying-on-heroku"},"children":[{"type":"text","value":"deploy the backend on Heruko"}]},{"type":"text","value":", and the "},{"type":"element","tagName":"a","properties":{"href":"https://docs.medusa-commerce.com/how-to/deploying-admin-on-netlify"},"children":[{"type":"text","value":"admin dashboard on Netlify"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"h2","properties":{"id":"medusas-cons"},"children":[{"type":"text","value":"Medusa's Cons"}]},{"type":"element","tagName":"h3","properties":{"id":"no-internationalization"},"children":[{"type":"text","value":"No Internationalization"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"At the moment of writing this, Medusa does not support multiple languages. Internationalization is a very important aspect of e-commerce."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"So, if your store needs to support languages other than the English language, then Medusa is not a good option."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Medusa's "},{"type":"element","tagName":"a","properties":{"href":"https://roadmap.medusa-commerce.com/c/8-localizations-api"},"children":[{"type":"text","value":"roadmap"}]},{"type":"text","value":" shows that Localization is a planned task. So, in the future, it should be available."}]},{"type":"element","tagName":"h3","properties":{"id":"lack-of-community-plugins"},"children":[{"type":"text","value":"Lack of Community Plugins"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"As Medusa is relatively new, at the moment there aren't many plugins created by the community to add custom functionalities to a Medusa store."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This is especially essential when it comes to payment and shipment integrations. Medusa comes with support for Stripe by default. Any additional payment or shipment services integration needs to be developed by you."}]},{"type":"element","tagName":"h3","properties":{"id":"simple-storefront"},"children":[{"type":"text","value":"Simple Storefront"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Although we all love simplicity, the storefronts that Medusa currently provides are too simple. For example, although you can add multiple regions or currencies in the admin panel, there's no way to actually switch between them when using the storefronts Medusa provides."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This won't be a problem if you're mostly relying on Medusa's headless commerce backend, or you're looking to customize your frontend as necessary for you. However, if you need to use the frontend as is with additional development, then you need to consider this first."}]},{"type":"element","tagName":"h2","properties":{"id":"when-should-you-use-medusa"},"children":[{"type":"text","value":"When Should You Use Medusa"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Medusa is the perfect option if you are looking for headless commerce. With its easy setup, you can have a headless commerce backend ready in a few minutes."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Medusa is also perfect if you're looking for complete freedom when designing your storefront. Even if you use one of its storefronts, you can easily make changes to the design as you find fitting."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Medusa is also one of the very few options available to build e-commerce stores with modern technologies."}]},{"type":"element","tagName":"h2","properties":{"id":"conclusion"},"children":[{"type":"text","value":"Conclusion"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Medusa is still an evolving e-commerce platform. Yet, it still offers promising results compared to a lot of other e-commerce platforms when it comes to performance, customization, and other pros we've discussed throughout the article."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can get started with Medusa in minutes with their "},{"type":"element","tagName":"a","properties":{"href":"https://docs.medusa-commerce.com/quickstart/quick-start"},"children":[{"type":"text","value":"Quickstart documentation."}]}]}],"data":{"quirksMode":false}},"tableOfContents":[{"id":"medusas-architecture","heading":"Medusa's Architecture "},{"id":"e-commerce-features","heading":"E-Commerce Features","items":[{"id":"product-variants","heading":"Product Variants"},{"id":"discounts","heading":"Discounts"},{"id":"gift-cards","heading":"Gift Cards"},{"id":"multiple-currencies","heading":"Multiple Currencies"},{"id":"multiple-regions","heading":"Multiple Regions"}]},{"id":"medusas-strong-points","heading":"Medusa's Strong Points","items":[{"id":"blazingly-fast","heading":"Blazingly Fast"},{"id":"highly-customizable","heading":"Highly Customizable"},{"id":"easy-development","heading":"Easy Development"},{"id":"easy-setup-and-deployment","heading":"Easy Setup and Deployment"}]},{"id":"medusas-cons","heading":"Medusa's Cons","items":[{"id":"no-internationalization","heading":"No Internationalization"},{"id":"lack-of-community-plugins","heading":"Lack of Community Plugins"},{"id":"simple-storefront","heading":"Simple Storefront"}]},{"id":"when-should-you-use-medusa","heading":"When Should You Use Medusa"},{"id":"conclusion","heading":"Conclusion"}]},"featureImageSharp":{"base":"Fast-and-Highly-Customizable-E-commerce-Stores.png","publicURL":"/static/b8bc41e18ef83364e45ba3fb6a77ad91/Fast-and-Highly-Customizable-E-commerce-Stores.png","imageMeta":{"width":1080,"height":1080},"childImageSharp":{"fluid":{"base64":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAB0klEQVQ4y+WUzWsTQRTA94/1LhQP4qF48SAUhCDSg/gBovZgtYrgVyNCLMVqtVHSbNJN0k1i0LbJ7maT7NfsT2biLts0CQa9+djHezsz+5s3895bjX8s2n8IjOMYqVKkFRPvib8QUIrIfhjLJ0YIkWoCz/pZTQLQsjAn9tkRHcSYeEbmRZuAtQRmxjYXw3cshXmuhFsIQDdM9EaTz6VqCjs4bOMHgfKj39FnN9OieDywFu2Tiz4q/7z3GpMh9x+94tzyCpev3+XStZvk7q2zdPUGt9dfsPrwKSu31tRcfns33SCNcE/8UNHlok9cCPI4BBiNNhv593wo7vNks8DLwg7P3m4pffymoOyD55t8rdTGeZDA7B2WxTF3oiI/4wGIxcolPXI2S57r0ay0aZgdqoctDLPNbqlKUa9Rb3WoNFro9abSvfIB219K2H33dFKywFAIvDDgqGdhmN8VQB6nqBsp6Fu1TrlmMvJ8PN9X93YKOK0kgiCk5/Tp2g6OO+DEcpRvOS7HPZuu5cwsJy07sEhnTCvqM708CU67Y0pnTILm/hz+JMpZa7RZC6V1hyOsvqvuTmazPxgyHHkzo5sLlCIhR12LE8tWViZGbrIQ8G+P/AsD7A56k5u11wAAAABJRU5ErkJggg==","aspectRatio":1,"src":"/static/b8bc41e18ef83364e45ba3fb6a77ad91/60290/Fast-and-Highly-Customizable-E-commerce-Stores.png","srcSet":"/static/b8bc41e18ef83364e45ba3fb6a77ad91/847ef/Fast-and-Highly-Customizable-E-commerce-Stores.png 175w,\n/static/b8bc41e18ef83364e45ba3fb6a77ad91/91cba/Fast-and-Highly-Customizable-E-commerce-Stores.png 350w,\n/static/b8bc41e18ef83364e45ba3fb6a77ad91/60290/Fast-and-Highly-Customizable-E-commerce-Stores.png 700w,\n/static/b8bc41e18ef83364e45ba3fb6a77ad91/f5f50/Fast-and-Highly-Customizable-E-commerce-Stores.png 1050w,\n/static/b8bc41e18ef83364e45ba3fb6a77ad91/14010/Fast-and-Highly-Customizable-E-commerce-Stores.png 1080w","srcWebp":"/static/b8bc41e18ef83364e45ba3fb6a77ad91/89afa/Fast-and-Highly-Customizable-E-commerce-Stores.webp","srcSetWebp":"/static/b8bc41e18ef83364e45ba3fb6a77ad91/9fca7/Fast-and-Highly-Customizable-E-commerce-Stores.webp 175w,\n/static/b8bc41e18ef83364e45ba3fb6a77ad91/37a4e/Fast-and-Highly-Customizable-E-commerce-Stores.webp 350w,\n/static/b8bc41e18ef83364e45ba3fb6a77ad91/89afa/Fast-and-Highly-Customizable-E-commerce-Stores.webp 700w,\n/static/b8bc41e18ef83364e45ba3fb6a77ad91/78e7a/Fast-and-Highly-Customizable-E-commerce-Stores.webp 1050w,\n/static/b8bc41e18ef83364e45ba3fb6a77ad91/788b4/Fast-and-Highly-Customizable-E-commerce-Stores.webp 1080w","sizes":"(max-width: 700px) 100vw, 700px"}}}},"next":{"id":"Ghost__Post__615c29963eea8f060129b225","title":"Top 9 Software Ideas for Start-Ups for The Year 2022","slug":"top-9-software-ideas-for-start-ups-for-the-year-2022","featured":false,"feature_image":"https://backend.shahednasser.com/content/images/2021/10/austin-distel-rxpThOwuVgE-unsplash-2-2.jpg","excerpt":"Given the rapid advancement of new technologies in recent years, the software development sector is one that should be pursued.","custom_excerpt":"Given the rapid advancement of new technologies in recent years, the software development sector is one that should be pursued.","visibility":"public","created_at_pretty":"5 Oct 2021","published_at_pretty":"5 Oct 2021","updated_at_pretty":"5 Oct 2021","created_at":"2021-10-05T10:31:50.000+00:00","published_at":"2021-10-05T11:24:22.000+00:00","updated_at":"2021-10-05T11:49:41.000+00:00","meta_title":null,"meta_description":null,"og_description":null,"og_image":null,"og_title":null,"twitter_description":null,"twitter_image":null,"twitter_title":null,"authors":[{"slug":"akash","url":"https://backend.shahednasser.com/author/akash/","name":"Akash Tripathi","bio":"Digital Marketer at Top Mobile Tech. I cover all the tips & tricks related to Mobile and tech. We bring the latest and critical news to your mobile and computer devices.","cover_image":null,"profile_image":"https://backend.shahednasser.com/content/images/2021/10/unnamed-1.png","location":null,"website":null,"twitter":null,"facebook":null,"meta_title":null,"meta_description":null,"coverImageSharp":null,"profileImageSharp":null}],"primary_author":{"slug":"akash","url":"https://backend.shahednasser.com/author/akash/","name":"Akash Tripathi","bio":"Digital Marketer at Top Mobile Tech. I cover all the tips & tricks related to Mobile and tech. We bring the latest and critical news to your mobile and computer devices.","cover_image":null,"profile_image":"https://backend.shahednasser.com/content/images/2021/10/unnamed-1.png","location":null,"website":null,"twitter":null,"facebook":null,"meta_title":null,"meta_description":null,"coverImageSharp":null,"profileImageSharp":{"base":"unnamed-1.png","publicURL":"/static/69bf109cd910b102ed4beb9e554a4581/unnamed-1.png","imageMeta":{"width":200,"height":200},"childImageSharp":{"fluid":{"base64":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAACXBIWXMAAAsTAAALEwEAmpwYAAAEV0lEQVQ4y22Se0xTZxjG3+/7zqU9p6e3QwvUtrRKFVCL1BYvdCqCongD8QJDwwbiLOIFcG4G3AI6/UPFBUxAIKK7KIvgNhaUZQO2qfHyB8G5sYgOVIR5ISjMFUHwLOAWk7nn3/f95X2eJy8AAEFIjhD8K4KQQDMCw4o8b9NrFAwN8Gr6X2FAKoLxPxtIRtEiJ+dZViWXW7Rqg0oFiKD/5VUySsfR/jJawxBBxrAURWGMEcYYCzLOaRSdBl5FCAaE0Gu8TZTbDYKWoRQYOU06l8WXYIIR0dD0NLXyq6zInoq4usxQoyADeI22iVyYUWU3imaN4DL5zpxgAEAuf74yMbjaEz1cl9tfs/FReeSGMPVoHfgVP2okWCeEW7SOAN0Uf63TKMaGGGig0u2an/e5m0vTr5Vk/lG1+dLe+WlOPQI0GuflfYQIwhBmFF0WX44mShnjMCjbDqV8tNxxZIW5Omnqvjj3yRRH4+5FhUtD06dZfRQ8gxEzFh2/hN+YaHAHGVmCJ+g1oeOUt0tSftwVc257cEdF8uWCNb8dWtVevLZxm7MkaSrLMALGHMJkjCSAYN7kcXNCTAqKhAcax4uqwnXhzQXLT60z9Z/JkZrKek/l3C1P666Iqy9YCgAsxixC9Jh5XsbCArvFHWRUyxh3iNXio0pfsbBqpfVIFNdyeNHtyqyWw5u+z1ny3ZbpGTEhACAQIkeIRQgDTDD7wbIZge5gs59SPisowCZyVSc/aTlXfXCxrX5H0PXi1efzVjVkxJzeFB7op8YASoI4hFkAOSEWgwipK1wRwQE6nrFb9LF288G0hFv3n7Q2X/s8J75m+/QbZZ6u8tQdy4IAQE0TAWMFwTwhAJC4chF41swOt43jERTlZ175tvLdxa6qo2WPB6S23x/WHi2qyn4zLymKo0BBaB+a1tCUiiYCTQHArux3IH/n8okG0eyrvXn1zLPuqzevfl28J7u2tq69s6/74Yua41VzZs7y0WgBQIaRhqHUNMVTo3Bp4YeQm7MkPNi8572Nf3Zd9vZce/64te/WxV8vfNlxo7WtrfvYgQ/SEhZuzfLk5WaFBFoBgCMUizEAFO7PgyxPQtz8Gb9crJGedYwM3hse7Bz23n72qLWr7UJTffXa5AQTx20M8E+MiUxJXT/JYmZomqFpUa1W8krYkTwvNsjw6YmPJal3yNs54u0cenpHknpyczYbKSaKIoU6+VmDMp+FueONPzVU19eUJscvMBn8R//7eLwrWQ7pGamS9GTY2zkycG+wr12Send7NuxlocGiabQoyvxVTXqhziw6NMKB/bvOf3Mif6cn0GqG3IjJRWYm1D7lr/526fn9FwNdI0/vPO3rWOeeXePHXHFq9+r5RJNYpFfXKxXlakWqThUdGTH0oPn6D6ehcMvqeofaysnOnvtCkvqGvZ1DfR3SyIP3316fyJP0Sfpoh23b1lUxgcYKjj0mKj8TBStAVuZb3ruX/gYqhFKKHuhYzwAAAABJRU5ErkJggg==","aspectRatio":1,"src":"/static/69bf109cd910b102ed4beb9e554a4581/6ccb0/unnamed-1.png","srcSet":"/static/69bf109cd910b102ed4beb9e554a4581/7d89d/unnamed-1.png 28w,\n/static/69bf109cd910b102ed4beb9e554a4581/f4091/unnamed-1.png 55w,\n/static/69bf109cd910b102ed4beb9e554a4581/6ccb0/unnamed-1.png 110w,\n/static/69bf109cd910b102ed4beb9e554a4581/30481/unnamed-1.png 165w,\n/static/69bf109cd910b102ed4beb9e554a4581/8ac63/unnamed-1.png 200w","srcWebp":"/static/69bf109cd910b102ed4beb9e554a4581/8678c/unnamed-1.webp","srcSetWebp":"/static/69bf109cd910b102ed4beb9e554a4581/59cda/unnamed-1.webp 28w,\n/static/69bf109cd910b102ed4beb9e554a4581/7da75/unnamed-1.webp 55w,\n/static/69bf109cd910b102ed4beb9e554a4581/8678c/unnamed-1.webp 110w,\n/static/69bf109cd910b102ed4beb9e554a4581/f282e/unnamed-1.webp 165w,\n/static/69bf109cd910b102ed4beb9e554a4581/6b183/unnamed-1.webp 200w","sizes":"(max-width: 110px) 100vw, 110px"}}}},"primary_tag":{"slug":"tips","url":"https://backend.shahednasser.com/tag/tips/","name":"Tips","visibility":"public","feature_image":null,"description":"Learn more about programming and development through these articles that have essential tips!","meta_title":"Tips on Technology and Programming","meta_description":null,"featureImageSharp":null},"tags":[{"slug":"tips","url":"https://backend.shahednasser.com/tag/tips/","name":"Tips","visibility":"public","feature_image":null,"description":"Learn more about programming and development through these articles that have essential tips!","meta_title":"Tips on Technology and Programming","meta_description":null,"featureImageSharp":null},{"slug":"business","url":"https://backend.shahednasser.com/tag/business/","name":"Business","visibility":"public","feature_image":"https://res-3.cloudinary.com/hbqmf3mbz/image/upload/q_auto/v1/ghost-blog-images/floriane-vita-FyD3OWBuXnY-unsplash-2.jpg","description":null,"meta_title":null,"meta_description":null,"featureImageSharp":null}],"plaintext":"Since the outbreak of the pandemic in March 2020, the use of new software\ntechnologies has grown at an amazing rate, increasing the need for custom\nsoftware solution providers. These on-demand software development companies\n[https://www.esparkinfo.com/custom-software-development.html] have raised more\nthan 200 percent of the developing cloud index's total capital and have a market\nvalue of around $2.4 trillion.\n\nGiven the rapid advancement of new technologies in recent years, the software\ndevelopment sector is one that should be pursued. As a result, these are the top\n9 software ideas for start-ups in 2022.\n\nManagement of Rental Properties\nOwnership of more than five homes or working as a real estate agent may make\nproperty management difficult. The goal is to develop an application that can\nassist an owner, a property agent, a renter, and a property joint management\norganization with the following:\n\n * Rental collecting, reminders for payments, and receipts for payments.\n * For smooth payment collection, integrate online payment and e-wallet.\n * Upkeep and repair.\n * Management of complaints and feedback.\n * Management by commission.\n\nInvestor Journal\nInvestors are advised to keep track of their buy and sell orders so they may\nlook back and reflect on the lessons they've learned.\n\nUsing the collected expertise stored in this program, investors may revise and\nexamine previous investments in order to enhance their performance.\n\nChatbot Solution Powered by Virtual AI\nSince 2014, the number of people who shop digitally has increased dramatically.\n\nIn 2021, there will be 2.14 billion digital purchasers out of a total population\nof 7.78 billion, a 4.4 percent growth year over year.\n\nEventually, every firm will have to go online. A chatbot and virtual assistant\nwill dramatically enhance the customer experience, conversion, and selling. It\nwould be ideal if it could link to the most popular social media platforms such\nas Instagram, Facebook, Telegram, WhatsApp, and WeChat to enable seamless\nautomation.\n\nCollaborative Tool for Teams and Platform for Team Development\nWorking from home has become the new normal for employees worldwide. Companies\nrequire tools for team collaboration in order to maintain team cohesion, smooth\ntask delegation, project management, and documentation.\n\nThe global market for team collaboration software is estimated at $27.8 billion\nby 2028 as per Global Newswire\n[https://www.globenewswire.com/news-release/2021/07/27/2269668/0/en/Team-Collaboration-Software-Market-Value-Predicted-To-Reach-US-27-8-Billion-By-2028-Covering-COVID-19-ERA-Acumen-Research-and-Consulting.html]\n.\n\nAdditionally, 24% of respondents reported experiencing video meeting fatigue,\n19% report having difficulty interacting in real-time (preferring not to connect\nthrough email or messenger), and 17% report finding it more difficult to manage\nprofessional relationships. – Survey conducted by Flexjobs\n[https://www.flexjobs.com/blog/post/flexjobs-survey-finds-employees-want-remote-work-post-pandemic/]\n.\n\nA platform for team development would greatly enhance communication and\nrelationships among team members. To keep users socially engaged, the platform\ncan incorporate aspects of different gaming activities (such as the game\ndepicted above), team interaction capabilities, beautiful visuals, and music.\n\nDespite the fact that there are many collaborations and team-building\ntechnologies available on the market, demand for them continues to grow at an\nexponential rate.\n\nDevelop a Medical Software Program\nMedical Software manages patients' computerized medical records. Numerous\nclinics and hospitals seek an alternative to error-prone manual patient data\ninput. In this way, you may educate clinics and hospitals about the advantages\nof the medical software you're developing and sell them on it.\n\nBy Statista, medical software is predicted to reach $4.26 billion\n[https://www.statista.com/statistics/866501/medical-imaging-analytics-software-market-size-worldwide/] \nin global sales by 2025. As can be seen, there are several changes in this\nfield. There are many healthcare software development businesses\n[https://www.topmobiletech.com/top-software-development-companies/] that may\nassist you in developing medical software and bringing your idea to life.\n\n[https://yiro6gzu369.typeform.com/to/bmKKNVlh]Itinerary Maker for Trips\nAlthough the tourist business appears to be suffering at the moment, this sector\nis poised for rapid expansion after the epidemic is over.\n\nIt may be hard to plan a trip schedule. We'll need distance, location,\nsuggestions, and budget information to decide which POIs (points of interest)\nfit within the schedule.\n\nWhen using a trip itinerary planner, all of the relevant information is gathered\nin one location, and destinations can be effortlessly dragged and dropped. It is\npreferable if the planner can automatically optimize the schedule for distance\nand cost of travel. Additionally, posting tailored vacation itineraries will\nsignificantly boost the platform's network impact.\n\nSolutions for Email Delivery\nModern life is dominated by online activities such as shopping, ordering takeout\nor delivery, communicating, participating in sports, banking, and attending\nmeetings or conventions. When it comes to transactional services like\nregistration of an account, reset the password, confirmation, financial\ntransactions, and marketing, email delivery plays a critical role.\n\nNumerous enhancements are possible, including user interface, ease of setup,\ncustomer experience, and cost.\n\nPassword Organiser\nThere are 80 applications on average for every smartphone user\n[https://www.socialmediatoday.com/news/60-fascinating-smartphone-apps-usage-statistics-for-2019-infographic/550990/]\n. In other words, users will have to keep track of at least 80 distinct sets of\nlogin credentials. Password reuse is a security risk because even if one app\ndatabase is compromised, it might compromise other accounts that use the same\npassword.\n\nPassword manager solves this problem by assisting you in creating and\nremembering a unique password for each account. Then, secure the master account\nusing several levels of security, such as two-factor verification or Google\nAuthentication protocol.\n\nPlatform for Online Training and Coaching\nSince the epidemic, many individuals worldwide have begun teaching online and\nproviding coaching services. It's reasonable to manage all members on a personal\nFacebook page, but branding, professionalism, and a payment mechanism are all\nmissing in action.\n\nThe purpose of this platform is to enable coaches to post multimedia recordings,\nlectures, and tutoring sessions. Exams, quizzes, and completion certificates can\nall be used to engage pupils. Automated membership money collection from\nsubscribers, allowing the coach to focus on providing outstanding material\ninstead.\n\nConclusion\nWhile software products may expand at an insane rate due to their extensibility\nas software, the work and expense associated with developing effective software\ncan be rather high. Create a minimum viable product (MVP) first, and then get\nsome early consumers on board to offer you valuable feedback.","html":"<p>Since the outbreak of the pandemic in March 2020, the use of new software technologies has grown at an amazing rate, increasing the need for custom software solution providers. These <a href=\"https://www.esparkinfo.com/custom-software-development.html\">on-demand software development companies</a> have raised more than 200 percent of the developing cloud index's total capital and have a market value of around $2.4 trillion.</p><p>Given the rapid advancement of new technologies in recent years, the software development sector is one that should be pursued. As a result, these are the top 9 software ideas for start-ups in 2022.</p><h2 id=\"management-of-rental-properties\">Management of Rental Properties</h2><p>Ownership of more than five homes or working as a real estate agent may make property management difficult. The goal is to develop an application that can assist an owner, a property agent, a renter, and a property joint management organization with the following:</p><ul><li>Rental collecting, reminders for payments, and receipts for payments.</li><li>For smooth payment collection, integrate online payment and e-wallet.</li><li>Upkeep and repair.</li><li>Management of complaints and feedback.</li><li>Management by commission.</li></ul><h2 id=\"investor-journal\">Investor Journal</h2><p>Investors are advised to keep track of their buy and sell orders so they may look back and reflect on the lessons they've learned.</p><p>Using the collected expertise stored in this program, investors may revise and examine previous investments in order to enhance their performance.</p><h2 id=\"chatbot-solution-powered-by-virtual-ai\">Chatbot Solution Powered by Virtual AI</h2><p>Since 2014, the number of people who shop digitally has increased dramatically.</p><p>In 2021, there will be 2.14 billion digital purchasers out of a total population of 7.78 billion, a 4.4 percent growth year over year.</p><p>Eventually, every firm will have to go online. A chatbot and virtual assistant will dramatically enhance the customer experience, conversion, and selling. It would be ideal if it could link to the most popular social media platforms such as Instagram, Facebook, Telegram, WhatsApp, and WeChat to enable seamless automation.</p><h2 id=\"collaborative-tool-for-teams-and-platform-for-team-development\">Collaborative Tool for Teams and Platform for Team Development</h2><p>Working from home has become the new normal for employees worldwide. Companies require tools for team collaboration in order to maintain team cohesion, smooth task delegation, project management, and documentation.</p><p>The global market for team collaboration software is estimated at $27.8 billion by 2028 as per <a href=\"https://www.globenewswire.com/news-release/2021/07/27/2269668/0/en/Team-Collaboration-Software-Market-Value-Predicted-To-Reach-US-27-8-Billion-By-2028-Covering-COVID-19-ERA-Acumen-Research-and-Consulting.html\">Global Newswire</a>.</p><p>Additionally, 24% of respondents reported experiencing video meeting fatigue, 19% report having difficulty interacting in real-time (preferring not to connect through email or messenger), and 17% report finding it more difficult to manage professional relationships. – <a href=\"https://www.flexjobs.com/blog/post/flexjobs-survey-finds-employees-want-remote-work-post-pandemic/\">Survey conducted by Flexjobs</a>.</p><p>A platform for team development would greatly enhance communication and relationships among team members. To keep users socially engaged, the platform can incorporate aspects of different gaming activities (such as the game depicted above), team interaction capabilities, beautiful visuals, and music.</p><p>Despite the fact that there are many collaborations and team-building technologies available on the market, demand for them continues to grow at an exponential rate.</p><h2 id=\"develop-a-medical-software-program\">Develop a Medical Software Program</h2><p>Medical Software manages patients' computerized medical records. Numerous clinics and hospitals seek an alternative to error-prone manual patient data input. In this way, you may educate clinics and hospitals about the advantages of the medical software you're developing and sell them on it.</p><p>By Statista, <a href=\"https://www.statista.com/statistics/866501/medical-imaging-analytics-software-market-size-worldwide/\">medical software is predicted to reach $4.26 billion</a> in global sales by 2025. As can be seen, there are several changes in this field. There are many healthcare <a href=\"https://www.topmobiletech.com/top-software-development-companies/\">software development businesses</a> that may assist you in developing medical software and bringing your idea to life.</p><!--kg-card-begin: html--><a href=\"https://yiro6gzu369.typeform.com/to/bmKKNVlh\"><img src=\"https://res.cloudinary.com/shahed/image/upload/v1633434557/Place_your_Ad_here_178_x_100_px_-3_kvf6uo.png\" alt=\"Place Your Ad Here\" /></a><!--kg-card-end: html--><h2 id=\"itinerary-maker-for-trips\">Itinerary Maker for Trips</h2><p>Although the tourist business appears to be suffering at the moment, this sector is poised for rapid expansion after the epidemic is over.</p><p>It may be hard to plan a trip schedule. We'll need distance, location, suggestions, and budget information to decide which POIs (points of interest) fit within the schedule.</p><p>When using a trip itinerary planner, all of the relevant information is gathered in one location, and destinations can be effortlessly dragged and dropped. It is preferable if the planner can automatically optimize the schedule for distance and cost of travel. Additionally, posting tailored vacation itineraries will significantly boost the platform's network impact.</p><h2 id=\"solutions-for-email-delivery\">Solutions for Email Delivery</h2><p>Modern life is dominated by online activities such as shopping, ordering takeout or delivery, communicating, participating in sports, banking, and attending meetings or conventions. When it comes to transactional services like registration of an account, reset the password, confirmation, financial transactions, and marketing, email delivery plays a critical role.</p><p>Numerous enhancements are possible, including user interface, ease of setup, customer experience, and cost.</p><h2 id=\"password-organiser\">Password Organiser</h2><p>There are <a href=\"https://www.socialmediatoday.com/news/60-fascinating-smartphone-apps-usage-statistics-for-2019-infographic/550990/\">80 applications on average for every smartphone user</a>. In other words, users will have to keep track of at least 80 distinct sets of login credentials. Password reuse is a security risk because even if one app database is compromised, it might compromise other accounts that use the same password.</p><p>Password manager solves this problem by assisting you in creating and remembering a unique password for each account. Then, secure the master account using several levels of security, such as two-factor verification or Google Authentication protocol.</p><h2 id=\"platform-for-online-training-and-coaching\">Platform for Online Training and Coaching</h2><p>Since the epidemic, many individuals worldwide have begun teaching online and providing coaching services. It's reasonable to manage all members on a personal Facebook page, but branding, professionalism, and a payment mechanism are all missing in action.</p><p>The purpose of this platform is to enable coaches to post multimedia recordings, lectures, and tutoring sessions. Exams, quizzes, and completion certificates can all be used to engage pupils. Automated membership money collection from subscribers, allowing the coach to focus on providing outstanding material instead.</p><h2 id=\"conclusion\">Conclusion</h2><p>While software products may expand at an insane rate due to their extensibility as software, the work and expense associated with developing effective software can be rather high. Create a minimum viable product (MVP) first, and then get some early consumers on board to offer you valuable feedback.</p>","url":"https://backend.shahednasser.com/top-9-software-ideas-for-start-ups-for-the-year-2022/","canonical_url":null,"uuid":"48471700-72e2-4392-bc28-e8bca0320c9e","codeinjection_foot":null,"codeinjection_head":null,"codeinjection_styles":null,"comment_id":"615c29963eea8f060129b225","reading_time":4,"send_email_when_published":null,"email_subject":null,"childHtmlRehype":{"html":"<p>Since the outbreak of the pandemic in March 2020, the use of new software technologies has grown at an amazing rate, increasing the need for custom software solution providers. These <a href=\"https://www.esparkinfo.com/custom-software-development.html\">on-demand software development companies</a> have raised more than 200 percent of the developing cloud index's total capital and have a market value of around $2.4 trillion.</p><p>Given the rapid advancement of new technologies in recent years, the software development sector is one that should be pursued. As a result, these are the top 9 software ideas for start-ups in 2022.</p><h2 id=\"management-of-rental-properties\">Management of Rental Properties</h2><p>Ownership of more than five homes or working as a real estate agent may make property management difficult. The goal is to develop an application that can assist an owner, a property agent, a renter, and a property joint management organization with the following:</p><ul><li>Rental collecting, reminders for payments, and receipts for payments.</li><li>For smooth payment collection, integrate online payment and e-wallet.</li><li>Upkeep and repair.</li><li>Management of complaints and feedback.</li><li>Management by commission.</li></ul><h2 id=\"investor-journal\">Investor Journal</h2><p>Investors are advised to keep track of their buy and sell orders so they may look back and reflect on the lessons they've learned.</p><p>Using the collected expertise stored in this program, investors may revise and examine previous investments in order to enhance their performance.</p><h2 id=\"chatbot-solution-powered-by-virtual-ai\">Chatbot Solution Powered by Virtual AI</h2><p>Since 2014, the number of people who shop digitally has increased dramatically.</p><p>In 2021, there will be 2.14 billion digital purchasers out of a total population of 7.78 billion, a 4.4 percent growth year over year.</p><p>Eventually, every firm will have to go online. A chatbot and virtual assistant will dramatically enhance the customer experience, conversion, and selling. It would be ideal if it could link to the most popular social media platforms such as Instagram, Facebook, Telegram, WhatsApp, and WeChat to enable seamless automation.</p><h2 id=\"collaborative-tool-for-teams-and-platform-for-team-development\">Collaborative Tool for Teams and Platform for Team Development</h2><p>Working from home has become the new normal for employees worldwide. Companies require tools for team collaboration in order to maintain team cohesion, smooth task delegation, project management, and documentation.</p><p>The global market for team collaboration software is estimated at $27.8 billion by 2028 as per <a href=\"https://www.globenewswire.com/news-release/2021/07/27/2269668/0/en/Team-Collaboration-Software-Market-Value-Predicted-To-Reach-US-27-8-Billion-By-2028-Covering-COVID-19-ERA-Acumen-Research-and-Consulting.html\">Global Newswire</a>.</p><p>Additionally, 24% of respondents reported experiencing video meeting fatigue, 19% report having difficulty interacting in real-time (preferring not to connect through email or messenger), and 17% report finding it more difficult to manage professional relationships. – <a href=\"https://www.flexjobs.com/blog/post/flexjobs-survey-finds-employees-want-remote-work-post-pandemic/\">Survey conducted by Flexjobs</a>.</p><p>A platform for team development would greatly enhance communication and relationships among team members. To keep users socially engaged, the platform can incorporate aspects of different gaming activities (such as the game depicted above), team interaction capabilities, beautiful visuals, and music.</p><p>Despite the fact that there are many collaborations and team-building technologies available on the market, demand for them continues to grow at an exponential rate.</p><h2 id=\"develop-a-medical-software-program\">Develop a Medical Software Program</h2><p>Medical Software manages patients' computerized medical records. Numerous clinics and hospitals seek an alternative to error-prone manual patient data input. In this way, you may educate clinics and hospitals about the advantages of the medical software you're developing and sell them on it.</p><p>By Statista, <a href=\"https://www.statista.com/statistics/866501/medical-imaging-analytics-software-market-size-worldwide/\">medical software is predicted to reach $4.26 billion</a> in global sales by 2025. As can be seen, there are several changes in this field. There are many healthcare <a href=\"https://www.topmobiletech.com/top-software-development-companies/\">software development businesses</a> that may assist you in developing medical software and bringing your idea to life.</p><!--kg-card-begin: html--><a href=\"https://yiro6gzu369.typeform.com/to/bmKKNVlh\"><img src=\"https://res.cloudinary.com/shahed/image/upload/v1633434557/Place_your_Ad_here_178_x_100_px_-3_kvf6uo.png\" alt=\"Place Your Ad Here\"></a><!--kg-card-end: html--><h2 id=\"itinerary-maker-for-trips\">Itinerary Maker for Trips</h2><p>Although the tourist business appears to be suffering at the moment, this sector is poised for rapid expansion after the epidemic is over.</p><p>It may be hard to plan a trip schedule. We'll need distance, location, suggestions, and budget information to decide which POIs (points of interest) fit within the schedule.</p><p>When using a trip itinerary planner, all of the relevant information is gathered in one location, and destinations can be effortlessly dragged and dropped. It is preferable if the planner can automatically optimize the schedule for distance and cost of travel. Additionally, posting tailored vacation itineraries will significantly boost the platform's network impact.</p><h2 id=\"solutions-for-email-delivery\">Solutions for Email Delivery</h2><p>Modern life is dominated by online activities such as shopping, ordering takeout or delivery, communicating, participating in sports, banking, and attending meetings or conventions. When it comes to transactional services like registration of an account, reset the password, confirmation, financial transactions, and marketing, email delivery plays a critical role.</p><p>Numerous enhancements are possible, including user interface, ease of setup, customer experience, and cost.</p><h2 id=\"password-organiser\">Password Organiser</h2><p>There are <a href=\"https://www.socialmediatoday.com/news/60-fascinating-smartphone-apps-usage-statistics-for-2019-infographic/550990/\">80 applications on average for every smartphone user</a>. In other words, users will have to keep track of at least 80 distinct sets of login credentials. Password reuse is a security risk because even if one app database is compromised, it might compromise other accounts that use the same password.</p><p>Password manager solves this problem by assisting you in creating and remembering a unique password for each account. Then, secure the master account using several levels of security, such as two-factor verification or Google Authentication protocol.</p><h2 id=\"platform-for-online-training-and-coaching\">Platform for Online Training and Coaching</h2><p>Since the epidemic, many individuals worldwide have begun teaching online and providing coaching services. It's reasonable to manage all members on a personal Facebook page, but branding, professionalism, and a payment mechanism are all missing in action.</p><p>The purpose of this platform is to enable coaches to post multimedia recordings, lectures, and tutoring sessions. Exams, quizzes, and completion certificates can all be used to engage pupils. Automated membership money collection from subscribers, allowing the coach to focus on providing outstanding material instead.</p><h2 id=\"conclusion\">Conclusion</h2><p>While software products may expand at an insane rate due to their extensibility as software, the work and expense associated with developing effective software can be rather high. Create a minimum viable product (MVP) first, and then get some early consumers on board to offer you valuable feedback.</p>","htmlAst":{"type":"root","children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Since the outbreak of the pandemic in March 2020, the use of new software technologies has grown at an amazing rate, increasing the need for custom software solution providers. These "},{"type":"element","tagName":"a","properties":{"href":"https://www.esparkinfo.com/custom-software-development.html"},"children":[{"type":"text","value":"on-demand software development companies"}]},{"type":"text","value":" have raised more than 200 percent of the developing cloud index's total capital and have a market value of around $2.4 trillion."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Given the rapid advancement of new technologies in recent years, the software development sector is one that should be pursued. As a result, these are the top 9 software ideas for start-ups in 2022."}]},{"type":"element","tagName":"h2","properties":{"id":"management-of-rental-properties"},"children":[{"type":"text","value":"Management of Rental Properties"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Ownership of more than five homes or working as a real estate agent may make property management difficult. The goal is to develop an application that can assist an owner, a property agent, a renter, and a property joint management organization with the following:"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Rental collecting, reminders for payments, and receipts for payments."}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"For smooth payment collection, integrate online payment and e-wallet."}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Upkeep and repair."}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Management of complaints and feedback."}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Management by commission."}]}]},{"type":"element","tagName":"h2","properties":{"id":"investor-journal"},"children":[{"type":"text","value":"Investor Journal"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Investors are advised to keep track of their buy and sell orders so they may look back and reflect on the lessons they've learned."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Using the collected expertise stored in this program, investors may revise and examine previous investments in order to enhance their performance."}]},{"type":"element","tagName":"h2","properties":{"id":"chatbot-solution-powered-by-virtual-ai"},"children":[{"type":"text","value":"Chatbot Solution Powered by Virtual AI"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Since 2014, the number of people who shop digitally has increased dramatically."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In 2021, there will be 2.14 billion digital purchasers out of a total population of 7.78 billion, a 4.4 percent growth year over year."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Eventually, every firm will have to go online. A chatbot and virtual assistant will dramatically enhance the customer experience, conversion, and selling. It would be ideal if it could link to the most popular social media platforms such as Instagram, Facebook, Telegram, WhatsApp, and WeChat to enable seamless automation."}]},{"type":"element","tagName":"h2","properties":{"id":"collaborative-tool-for-teams-and-platform-for-team-development"},"children":[{"type":"text","value":"Collaborative Tool for Teams and Platform for Team Development"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Working from home has become the new normal for employees worldwide. Companies require tools for team collaboration in order to maintain team cohesion, smooth task delegation, project management, and documentation."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The global market for team collaboration software is estimated at $27.8 billion by 2028 as per "},{"type":"element","tagName":"a","properties":{"href":"https://www.globenewswire.com/news-release/2021/07/27/2269668/0/en/Team-Collaboration-Software-Market-Value-Predicted-To-Reach-US-27-8-Billion-By-2028-Covering-COVID-19-ERA-Acumen-Research-and-Consulting.html"},"children":[{"type":"text","value":"Global Newswire"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Additionally, 24% of respondents reported experiencing video meeting fatigue, 19% report having difficulty interacting in real-time (preferring not to connect through email or messenger), and 17% report finding it more difficult to manage professional relationships. – "},{"type":"element","tagName":"a","properties":{"href":"https://www.flexjobs.com/blog/post/flexjobs-survey-finds-employees-want-remote-work-post-pandemic/"},"children":[{"type":"text","value":"Survey conducted by Flexjobs"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"A platform for team development would greatly enhance communication and relationships among team members. To keep users socially engaged, the platform can incorporate aspects of different gaming activities (such as the game depicted above), team interaction capabilities, beautiful visuals, and music."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Despite the fact that there are many collaborations and team-building technologies available on the market, demand for them continues to grow at an exponential rate."}]},{"type":"element","tagName":"h2","properties":{"id":"develop-a-medical-software-program"},"children":[{"type":"text","value":"Develop a Medical Software Program"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Medical Software manages patients' computerized medical records. Numerous clinics and hospitals seek an alternative to error-prone manual patient data input. In this way, you may educate clinics and hospitals about the advantages of the medical software you're developing and sell them on it."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"By Statista, "},{"type":"element","tagName":"a","properties":{"href":"https://www.statista.com/statistics/866501/medical-imaging-analytics-software-market-size-worldwide/"},"children":[{"type":"text","value":"medical software is predicted to reach $4.26 billion"}]},{"type":"text","value":" in global sales by 2025. As can be seen, there are several changes in this field. There are many healthcare "},{"type":"element","tagName":"a","properties":{"href":"https://www.topmobiletech.com/top-software-development-companies/"},"children":[{"type":"text","value":"software development businesses"}]},{"type":"text","value":" that may assist you in developing medical software and bringing your idea to life."}]},{"type":"comment","value":"kg-card-begin: html"},{"type":"element","tagName":"a","properties":{"href":"https://yiro6gzu369.typeform.com/to/bmKKNVlh"},"children":[{"type":"element","tagName":"img","properties":{"src":"https://res.cloudinary.com/shahed/image/upload/v1633434557/Place_your_Ad_here_178_x_100_px_-3_kvf6uo.png","alt":"Place Your Ad Here"},"children":[]}]},{"type":"comment","value":"kg-card-end: html"},{"type":"element","tagName":"h2","properties":{"id":"itinerary-maker-for-trips"},"children":[{"type":"text","value":"Itinerary Maker for Trips"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Although the tourist business appears to be suffering at the moment, this sector is poised for rapid expansion after the epidemic is over."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"It may be hard to plan a trip schedule. We'll need distance, location, suggestions, and budget information to decide which POIs (points of interest) fit within the schedule."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"When using a trip itinerary planner, all of the relevant information is gathered in one location, and destinations can be effortlessly dragged and dropped. It is preferable if the planner can automatically optimize the schedule for distance and cost of travel. Additionally, posting tailored vacation itineraries will significantly boost the platform's network impact."}]},{"type":"element","tagName":"h2","properties":{"id":"solutions-for-email-delivery"},"children":[{"type":"text","value":"Solutions for Email Delivery"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Modern life is dominated by online activities such as shopping, ordering takeout or delivery, communicating, participating in sports, banking, and attending meetings or conventions. When it comes to transactional services like registration of an account, reset the password, confirmation, financial transactions, and marketing, email delivery plays a critical role."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Numerous enhancements are possible, including user interface, ease of setup, customer experience, and cost."}]},{"type":"element","tagName":"h2","properties":{"id":"password-organiser"},"children":[{"type":"text","value":"Password Organiser"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"There are "},{"type":"element","tagName":"a","properties":{"href":"https://www.socialmediatoday.com/news/60-fascinating-smartphone-apps-usage-statistics-for-2019-infographic/550990/"},"children":[{"type":"text","value":"80 applications on average for every smartphone user"}]},{"type":"text","value":". In other words, users will have to keep track of at least 80 distinct sets of login credentials. Password reuse is a security risk because even if one app database is compromised, it might compromise other accounts that use the same password."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Password manager solves this problem by assisting you in creating and remembering a unique password for each account. Then, secure the master account using several levels of security, such as two-factor verification or Google Authentication protocol."}]},{"type":"element","tagName":"h2","properties":{"id":"platform-for-online-training-and-coaching"},"children":[{"type":"text","value":"Platform for Online Training and Coaching"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Since the epidemic, many individuals worldwide have begun teaching online and providing coaching services. It's reasonable to manage all members on a personal Facebook page, but branding, professionalism, and a payment mechanism are all missing in action."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The purpose of this platform is to enable coaches to post multimedia recordings, lectures, and tutoring sessions. Exams, quizzes, and completion certificates can all be used to engage pupils. Automated membership money collection from subscribers, allowing the coach to focus on providing outstanding material instead."}]},{"type":"element","tagName":"h2","properties":{"id":"conclusion"},"children":[{"type":"text","value":"Conclusion"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"While software products may expand at an insane rate due to their extensibility as software, the work and expense associated with developing effective software can be rather high. Create a minimum viable product (MVP) first, and then get some early consumers on board to offer you valuable feedback."}]}],"data":{"quirksMode":false}},"tableOfContents":[{"id":"management-of-rental-properties","heading":"Management of Rental Properties"},{"id":"investor-journal","heading":"Investor Journal"},{"id":"chatbot-solution-powered-by-virtual-ai","heading":"Chatbot Solution Powered by Virtual AI"},{"id":"collaborative-tool-for-teams-and-platform-for-team-development","heading":"Collaborative Tool for Teams and Platform for Team Development"},{"id":"develop-a-medical-software-program","heading":"Develop a Medical Software Program"},{"id":"itinerary-maker-for-trips","heading":"Itinerary Maker for Trips"},{"id":"solutions-for-email-delivery","heading":"Solutions for Email Delivery"},{"id":"password-organiser","heading":"Password Organiser"},{"id":"platform-for-online-training-and-coaching","heading":"Platform for Online Training and Coaching"},{"id":"conclusion","heading":"Conclusion"}]},"featureImageSharp":{"base":"austin-distel-rxpThOwuVgE-unsplash-2-2.jpg","publicURL":"/static/382c1a13ee4535f610bd499c71e81738/austin-distel-rxpThOwuVgE-unsplash-2-2.jpg","imageMeta":{"width":1920,"height":1080},"childImageSharp":{"fluid":{"base64":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAALABQDASIAAhEBAxEB/8QAFwAAAwEAAAAAAAAAAAAAAAAAAAMEBf/EABUBAQEAAAAAAAAAAAAAAAAAAAIB/9oADAMBAAIQAxAAAAGlT4AqDEFP/8QAGxABAAICAwAAAAAAAAAAAAAAAgABAxIRISL/2gAIAQEAAQUCtbZPE5EQOy6KVz//xAAXEQEAAwAAAAAAAAAAAAAAAAAAARJB/9oACAEDAQE/AcWl/8QAGBEAAgMAAAAAAAAAAAAAAAAAAAEREiH/2gAIAQIBAT8BySqP/8QAGhAAAgIDAAAAAAAAAAAAAAAAAAEhMREiQf/aAAgBAQAGPwJajxYpZQ2rFPD/xAAaEAADAQEBAQAAAAAAAAAAAAAAASERQTHR/9oACAEBAAE/IV6JZCRvHCUGoc+hzKhHKZQf/9oADAMBAAIAAwAAABCPz//EABYRAQEBAAAAAAAAAAAAAAAAAAEQMf/aAAgBAwEBPxAE1D//xAAZEQACAwEAAAAAAAAAAAAAAAAAATFhkfD/2gAIAQIBAT8QbaBf2n//xAAaEAEBAQEBAQEAAAAAAAAAAAABESEAMVGR/9oACAEBAAE/EALYDDI33i0SWJC15BlVMJ2prZ68417RUc/POHDqQfuvf//Z","aspectRatio":1.7857142857142858,"src":"/static/382c1a13ee4535f610bd499c71e81738/ea4ab/austin-distel-rxpThOwuVgE-unsplash-2-2.jpg","srcSet":"/static/382c1a13ee4535f610bd499c71e81738/477ba/austin-distel-rxpThOwuVgE-unsplash-2-2.jpg 175w,\n/static/382c1a13ee4535f610bd499c71e81738/06776/austin-distel-rxpThOwuVgE-unsplash-2-2.jpg 350w,\n/static/382c1a13ee4535f610bd499c71e81738/ea4ab/austin-distel-rxpThOwuVgE-unsplash-2-2.jpg 700w,\n/static/382c1a13ee4535f610bd499c71e81738/3055e/austin-distel-rxpThOwuVgE-unsplash-2-2.jpg 1050w,\n/static/382c1a13ee4535f610bd499c71e81738/eff08/austin-distel-rxpThOwuVgE-unsplash-2-2.jpg 1400w,\n/static/382c1a13ee4535f610bd499c71e81738/74fd5/austin-distel-rxpThOwuVgE-unsplash-2-2.jpg 1920w","srcWebp":"/static/382c1a13ee4535f610bd499c71e81738/89afa/austin-distel-rxpThOwuVgE-unsplash-2-2.webp","srcSetWebp":"/static/382c1a13ee4535f610bd499c71e81738/9fca7/austin-distel-rxpThOwuVgE-unsplash-2-2.webp 175w,\n/static/382c1a13ee4535f610bd499c71e81738/37a4e/austin-distel-rxpThOwuVgE-unsplash-2-2.webp 350w,\n/static/382c1a13ee4535f610bd499c71e81738/89afa/austin-distel-rxpThOwuVgE-unsplash-2-2.webp 700w,\n/static/382c1a13ee4535f610bd499c71e81738/78e7a/austin-distel-rxpThOwuVgE-unsplash-2-2.webp 1050w,\n/static/382c1a13ee4535f610bd499c71e81738/03d34/austin-distel-rxpThOwuVgE-unsplash-2-2.webp 1400w,\n/static/382c1a13ee4535f610bd499c71e81738/6833b/austin-distel-rxpThOwuVgE-unsplash-2-2.webp 1920w","sizes":"(max-width: 700px) 100vw, 700px"}}}},"allGhostPost":{"edges":[{"node":{"id":"Ghost__Post__61f9452160a9ab05cc5e689a","title":"How to Create a Notes App with Strapi v4 and React Native","slug":"how-to-create-notes-app-with-strapi-v4-and-react-native","featured":true,"feature_image":"https://backend.shahednasser.com/content/images/2022/03/How-to-Create-a-Notes-App-with-Strapi-v4-and-React-Native-5.webp","excerpt":"In this tutorial, you'll learn how to create a Notes app with Strapi v4 and React Native.","custom_excerpt":"In this tutorial, you'll learn how to create a Notes app with Strapi v4 and React Native.","visibility":"public","created_at_pretty":"1 Feb 2022","published_at_pretty":"8 Feb 2022","updated_at_pretty":"27 Mar 2022","created_at":"2022-02-01T14:35:13.000+00:00","published_at":"2022-02-08T10:23:54.000+00:00","updated_at":"2022-03-27T10:41:24.000+00:00","meta_title":null,"meta_description":null,"og_description":null,"og_image":null,"og_title":null,"twitter_description":null,"twitter_image":null,"twitter_title":null,"authors":[{"slug":"shahed","url":"https://backend.shahednasser.com/author/shahed/","name":"Shahed Nasser","bio":null,"cover_image":null,"profile_image":"https://backend.shahednasser.com/content/images/2022/03/IMG_0591.jpg","location":null,"website":null,"twitter":null,"facebook":null,"meta_title":null,"meta_description":null,"coverImageSharp":null,"profileImageSharp":null}],"primary_author":{"slug":"shahed","url":"https://backend.shahednasser.com/author/shahed/","name":"Shahed Nasser","bio":null,"cover_image":null,"profile_image":"https://backend.shahednasser.com/content/images/2022/03/IMG_0591.jpg","location":null,"website":null,"twitter":null,"facebook":null,"meta_title":null,"meta_description":null,"coverImageSharp":null,"profileImageSharp":{"base":"IMG_0591.jpg","publicURL":"/static/ceb49c3c631485453e71e00d7f84b069/IMG_0591.jpg","imageMeta":{"width":1182,"height":1179},"childImageSharp":{"fluid":{"base64":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAUABQDASIAAhEBAxEB/8QAGAABAQEBAQAAAAAAAAAAAAAAAAMEAQL/xAAWAQEBAQAAAAAAAAAAAAAAAAADBAL/2gAMAwEAAhADEAAAAdXiFM6i0CohUWXoKn//xAAcEAACAgIDAAAAAAAAAAAAAAACAwESBBEhM0H/2gAIAQEAAQUCWySE3WEr7SzbXjAj4iKty+sOQ//EABYRAQEBAAAAAAAAAAAAAAAAAAERIP/aAAgBAwEBPwEhj//EABQRAQAAAAAAAAAAAAAAAAAAACD/2gAIAQIBAT8BH//EAB4QAAIBBAMBAAAAAAAAAAAAAAABIRESMUECECJx/9oACAEBAAY/ApVGWvOjzgtUwLlTZA0sdL4f/8QAHBAAAwACAwEAAAAAAAAAAAAAAAERITFBkbHB/9oACAEBAAE/IahkCy+N2GwZpjQiJHJCspUFY0QrSi+HqiW2rgf/2gAMAwEAAgADAAAAEPw3/wD/xAAYEQEBAAMAAAAAAAAAAAAAAAAAARExQf/aAAgBAwEBPxCtjDqP/8QAFxEBAQEBAAAAAAAAAAAAAAAAAQAxEf/aAAgBAgEBPxBFus6Tt//EAB8QAQEAAgIBBQAAAAAAAAAAAAERACExQWFRcYGR0f/aAAgBAQABPxAuaBPPzkO1wyX7F4wkwXanfZrFQgeqE9JgS14vVOvrERIJomVBKwt2jebAeP0yVa8h1n//2Q==","aspectRatio":1,"src":"/static/ceb49c3c631485453e71e00d7f84b069/31709/IMG_0591.jpg","srcSet":"/static/ceb49c3c631485453e71e00d7f84b069/f340b/IMG_0591.jpg 28w,\n/static/ceb49c3c631485453e71e00d7f84b069/22d64/IMG_0591.jpg 55w,\n/static/ceb49c3c631485453e71e00d7f84b069/31709/IMG_0591.jpg 110w,\n/static/ceb49c3c631485453e71e00d7f84b069/aa249/IMG_0591.jpg 165w,\n/static/ceb49c3c631485453e71e00d7f84b069/0dc33/IMG_0591.jpg 220w,\n/static/ceb49c3c631485453e71e00d7f84b069/d8257/IMG_0591.jpg 1182w","srcWebp":"/static/ceb49c3c631485453e71e00d7f84b069/8678c/IMG_0591.webp","srcSetWebp":"/static/ceb49c3c631485453e71e00d7f84b069/59cda/IMG_0591.webp 28w,\n/static/ceb49c3c631485453e71e00d7f84b069/7da75/IMG_0591.webp 55w,\n/static/ceb49c3c631485453e71e00d7f84b069/8678c/IMG_0591.webp 110w,\n/static/ceb49c3c631485453e71e00d7f84b069/f282e/IMG_0591.webp 165w,\n/static/ceb49c3c631485453e71e00d7f84b069/a7b21/IMG_0591.webp 220w,\n/static/ceb49c3c631485453e71e00d7f84b069/63099/IMG_0591.webp 1182w","sizes":"(max-width: 110px) 100vw, 110px"}}}},"primary_tag":{"slug":"strapi","url":"https://backend.shahednasser.com/tag/strapi/","name":"Strapi","visibility":"public","feature_image":null,"description":null,"meta_title":null,"meta_description":null,"featureImageSharp":null},"tags":[{"slug":"strapi","url":"https://backend.shahednasser.com/tag/strapi/","name":"Strapi","visibility":"public","feature_image":null,"description":null,"meta_title":null,"meta_description":null,"featureImageSharp":null},{"slug":"react-native","url":"https://backend.shahednasser.com/tag/react-native/","name":"React Native","visibility":"public","feature_image":null,"description":null,"meta_title":null,"meta_description":null,"featureImageSharp":null},{"slug":"js","url":"https://backend.shahednasser.com/tag/js/","name":"Javascript","visibility":"public","feature_image":"https://backend.shahednasser.com/content/images/2022/01/photo-1592609931095-54a2168ae893-2.jpeg","description":"Learn more about Javascript through tutorials, articles, and tips.","meta_title":null,"meta_description":"Learn more about Javascript through tutorials, articles and tips.","featureImageSharp":null}],"plaintext":"Strapi [https://strapi.io] is a headless CMS framework that allows you to\nintegrate CMS functionalities into any of your technical stacks. This gives you\nmore flexibility when choosing the different components that make up your\nproject.\n\nOne of the many frameworks you can integrate Strapi to is React Native\n[https://reactnative.dev]. React Native is a cross-platform framework that\nallows you to write your code in JavaScript, then deploy it on Android and iOS.\n\nIn this tutorial, you'll learn how to create a Notes app with Strapi v4 and\nReact Native. You'll be able to add notes on the Strapi backend. Then, you'll be\nable to view, edit, create, and delete notes in the React Native app.\n\nYou can find the code for this tutorial on this GitHub repository\n[https://github.com/shahednasser/strapi-react-native].\n\nSetup Strapi\nIn your terminal, run the following command to install and setup Strapi:\n\nnpx create-strapi-app@latest strapi --quickstart\n\nThis will create a new directory called strapi, and, once the installation is\ndone, a new page will open in your default browser at the Strapi backend. It's\nusually at localhost:1337.\n\nYou'll need to create an admin user. Once you're done, you'll be redirected to\nthe admin dashboard.\n\nCreate Content-Types\nClick on Content-Type Builder on the sidebar. Then, click on Create new\ncollection type under Collection Types.\n\nIn the pop-up, enter Note for display name. Then click continue.\n\nYou'll create 3 fields:\n\n 1. title: of type Text. Make sure to set it required in the Advanced Settings\n    tab.\n 2. content: of type Rich Text. Make sure to set it required in the Advanced\n    Settings tab.\n 3. date: of type Date. Make sure to select datetime in the Type dropdown, and\n    set it required in the Advanced Settings tab.\n\nYou should have a Note collection type with the following fields:\n\nOnce you're done click Save.\n\nChange Permissions\nThe next step is to change permissions so that you can access the notes from\nReact Native.\n\nClick on Settings in the sidebar, then go to Roles under Users & Permissions\nPlugin. You'll see two entries in the table. Click on the edit icon for the\nPublic row.\n\nThen, scroll down. Under Permissions, click on Note to expand it, then select\nall permissions. Once you're done, click Save at the top right.\n\nSetup React Native\nNext, you'll set up a React Native project.\n\nFirst, you need to install the Expo CLI\n[https://docs.expo.dev/workflow/expo-cli/] if you don't have it installed:\n\nnpm i -g expo-cli\n\nNext, run the following command to create a new React Native project:\n\nexpo init notes-app\n\nChoose Blank when asked about the type of project to create.\n\nOnce that is done, change to the newly created directory notes-app and install\ndependencies with NPM:\n\ncd notes-app\nnpm i\n\nNow, you'll need to install the dependencies you'll need for this tutorial.\nFirst, start by installing some dependencies with Expo's CLI:\n\nexpo install react-native-screens react-native-safe-area-context\n\nThese dependencies are necessary to add React Navigation\n[https://reactnavigation.org], which is a library that adds navigation\ncapabilities between screens in your app.\n\nSuggested Read: React Native Navigation Tutorial.\n[https://blog.shahednasser.com/react-native-navigation-tutorial]\n\nNext, install the necessary dependencies with NPM:\n\nnpm i react-native-paper @react-navigation/native @react-navigation/native-stack react-native-pell-rich-editor react-native-webview\n\nHere's what each dependency is for:\n\n 1. react-native-paper: React Native Paper\n    [https://callstack.github.io/react-native-paper/index.html] library to\n    easily add styled-components in your app.\n 2. @react-navigation/native @react-navigation/native-stack: More libraries for\n    React Navigation.\n 3. react-native-pell-rich-editor: a Rich Editor\n    [https://github.com/wxik/react-native-rich-editor] element for React Native.\n 4. react-native-webview: required by react-native-pell-rich-editor.\n\nCreate Home Screen\nThe home screen displays a list of notes with just the title and the date. It\nwill also have a + button at the top right to add notes.\n\nCreate the file screens/HomeScreen.js with the following content:\n\nimport axios from \"axios\";\nimport { useEffect, useState } from \"react\";\nimport { FlatList, View } from \"react-native\";\nimport { Caption, List, Snackbar } from \"react-native-paper\";\n\nexport default function HomeScreen ({ navigation }) {\n  const [notes, setNotes] = useState([]);\n  const [loading, setLoading] = useState(true);\n  const [error, setError] = useState('');\n\n  useEffect(() => {\n    loadNotes()\n\n    const subscribe = navigation.addListener('focus', () => {\n      loadNotes();\n    });\n\n    return subscribe;\n  }, [])\n\n  function loadNotes () {\n    axios.get('http://<IP>:1337/api/notes')\n      .then(({ data }) => {\n        setNotes(data.data);\n        setLoading(false);\n      })\n      .catch((e) => {\n        console.error(e);\n        setError('An error occurred, please try again later.');\n        setLoading(false);\n      });\n  }\n\n  return (\n    <View>\n      {!loading && !notes.length && <Caption style={{textAlign: 'center', marginTop: 10}}>You have no notes</Caption>}\n      <FlatList\n        data={notes}\n        renderItem={({ item }) => (\n          <List.Item \n            key={item.id}\n            title={item.attributes.title}\n            description={item.attributes.date}\n            onPress={() => navigation.navigate('Editor', {\n                note: item\n            })}\n            />\n        )}      \n        refreshing={loading}\n        onRefresh={loadNotes}\n        style={{width: '100%', height: '100%'}}\n      />\n      <Snackbar visible={error.length > 0} onDismiss={() => setError('')}>{error}</Snackbar>\n    </View>\n  )\n}\n\nYou first create the state variable notes which will hold the notes when\nreceived from the Strapi backend. You use a FlatList\n[https://reactnative.dev/docs/flatlist] component to display the notes. This\nwill render each note using the List.Item\n[https://callstack.github.io/react-native-paper/list-item.html] component from\nReact Native Paper. The title of the item will be the title of the note, and the\ndescription will be the date of the note.\n\nWhen the item in the list is clicked, the user will be taken to the Editor \nscreen (which you'll create in the next section).\n\nThe fetching of the notes will happen in the loadNotes function. This function\nis called when the screen first opens, when the screen gains focus, and when the\nflat list is refreshed.\n\nIn the loadNotes function, you send a request to http://<IP>:1337/api/notes.\nNotice that to run the app on your phone, you need to use your machine's network\nIP. So, replace <IP> with your machine's IP.\n\nThis endpoint is Strapi's Endpoint for fetching the entries\n[https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest-api.html#get-entries] \nof a content type. You then set the notes state variable to the data received\nfrom Strapi.\n\nNext, you need to make changes to the App.js file to show different screens.\n\nOpen App.js and replace the content with the following:\n\nimport { NavigationContainer } from '@react-navigation/native';\nimport { createNativeStackNavigator } from '@react-navigation/native-stack';\nimport { IconButton } from 'react-native-paper';\nimport EditorScreen from './screens/EditorScreen';\nimport HomeScreen from './screens/HomeScreen';\n\nconst Stack = createNativeStackNavigator();\n\nexport default function App() {\n  return (\n    <NavigationContainer>\n      <Stack.Navigator>\n        <Stack.Screen name=\"Home\" component={HomeScreen} options={({navigation}) => ({\n          headerRight: () => (\n            <IconButton icon='plus' onPress={() => navigation.navigate('Editor')} />\n          )\n        })} />\n      </Stack.Navigator>\n    </NavigationContainer>\n  );\n}\n\n\nNotice that the Home screen has a button at the top right that will take you to\nthe Editor screen.\n\nNow, let's run the app. In your terminal, run the following:\n\nnpm start\n\nThis will allow you to open the app on iOS or Android. You'll need the Expo Go\n[https://expo.dev/client] app on your phone. Then, on Android, open the app and\nscan the QR code in the terminal or the developer tool page to open the app.\nAlternatively, on iOS, you need to scan the QR code in your Camera app which\nwill let you open the app in Expo Go.\n\nWhen you open the app, you'll see an empty home screen.\n\nCreate Editor Screen\nNow, you'll create the editor screen which will show the user the editor with\neither the content filled (if editing an existing note) or an empty rich text\neditor.\n\nCreate screens/EditorScreen.js with the following content:\n\nimport { useLayoutEffect, useRef, useState } from 'react';\nimport { RichEditor, RichToolbar} from \"react-native-pell-rich-editor\";\nimport { Keyboard, KeyboardAvoidingView, ScrollView, View } from 'react-native';\nimport { Button, Colors, Snackbar, Subheading, TextInput } from 'react-native-paper';\nimport axios from 'axios';\n\nexport default function EditorScreen ({ route, navigation }) {\n  const editor = useRef();\n  const [title, setTitle] = useState(route.params && route.params.note ? route.params.note.attributes.title : '');\n  const [content, setContent] = useState(route.params && route.params.note ? route.params.note.attributes.content : '');\n  const [error, setError] = useState('')\n\n  function saveNote () {\n    editor.current.blurContentEditor(); //lose focus for editor and close keyboard\n    Keyboard.dismiss();\n    const trimmedTitle = title.trim(),\n      trimmedContent = content.trim();\n    if (!trimmedTitle.length || !trimmedContent.length) {\n      setError('Please fill both title and content');\n      return;\n    }\n    axios({\n      method: route.params && route.params.note ? 'PUT' : 'POST',\n      url: 'http://<IP>:1337/api/notes' + (route.params && route.params.note ? '/' + route.params.note.id : ''),\n      data: {\n        data: {\n          title,\n          content,\n          date: Date.now()\n        }\n      }\n    }).then(() => {\n      //redirect back to home screen\n      navigation.goBack();\n    })\n    .catch((e) => {\n      console.error(e);\n      setError('An error occurred, please try again later')\n    })\n  }\n\n  function deleteNote () {\n    axios.delete('http://<IP>:1337/api/notes/' + route.params.note.id)\n      .then(() => {\n        //redirect back to home screen\n      navigation.goBack();\n      })\n      .catch((e) => {\n        console.error(e);\n        setError('An error occurred, please try again later.');\n      })\n  }\n\n  useLayoutEffect(() => {\n    navigation.setOptions({\n      headerTitle: content.length === 0 ? 'New Note' : 'Edit Note',\n      headerRight: route.params && route.params.note ? () => (\n        <Button color={Colors.redA100} onPress={deleteNote}>Delete</Button>\n      ) : () => (<></>)\n    });\n  }, []);\n\n  return (\n    <View style={{margin: 10, flex: 1, justifyContent: 'space-between'}}>\n      <TextInput label=\"Title\" value={title} onChangeText={setTitle} mode=\"outlined\" />\n      <Subheading>Content</Subheading>\n      <RichToolbar\n        editor={editor}\n      />\n      <ScrollView keyboardDismissMode='onDrag'>\n        <KeyboardAvoidingView behavior={\"position\"}\tstyle={{ flex: 1 }} keyboardVerticalOffset={250}>\n          <RichEditor \n            style={{ flex: 1}}\n            ref={editor} \n            onChange={setContent} \n            initialContentHTML={content} \n            placeholder='Start typing...'\n            useContainer />\n          <Button onPress={saveNote} mode=\"contained\" style={{marginTop: 20}}>\n            Save\n          </Button>\n        </KeyboardAvoidingView>\n      </ScrollView>\n      <Snackbar visible={error.length > 0} onDismiss={() => setError('')}>{error}</Snackbar>\n    </View>\n  )\n}\n\nIn this code snippet, you create a editor ref variable for the Rich text editor.\nThis is necessary for the library you're using. You also create a title and \ncontent state variables. These will be used to store the input values and will\nhave as initial values the note's title and content if it exists.\n\nOn the screen, you show a rich text editor with a toolbar to add advanced text\nediting. You also add a Save button and a Delete button for existing notes.\n\nSave a Note\nWhen the Save button is clicked, you check if the note exists or is new. If the\nnote already exists, then, a PUT request is sent to \nhttp://<IP>:1337/api/notes/<note_id>, where <IP> is your machine's IP and \n<note_id> is the current note's ID. This Strapi endpoint is used to update an\nentry\n[https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest-api.html#update-an-entry] \nin a collection.\n\nAlternatively, if the note is new, a POST request is sent to \nhttp://<IP>:1337/api/notes, where <IP> is your machine's IP. This Strapi\nendpoint is used to create an entry\n[https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest-api.html#create-an-entry]\n.\n\nBoth requests accept in the body of the request a data parameter with the\nentry's data. You pass the title, content, and current date.\n\nDelete a Note\nWhen the Delete Button is clicked, a DELETE request is sent to \nhttp://<IP>:1337/api/notes/<note_id>, where <IP> is your machine's IP and \n<note_id> is the ID of the note to delete. Remember, this is only available if\nthe note exists.\n\nAfter the note is saved or deleted, you take the user back to the home screen.\n\nNext, you need to add the new screen to App.js. Add it after the Home screen:\n\n<Stack.Screen name=\"Editor\" component={EditorScreen} />\n\nThat's all, now run the app if it's not running. Try first clicking on the + \nbutton at the top right of the home screen. You'll see a rich text editor with a\ntoolbar and a Save button.\n\nAdd a Note\nTry entering any content in both title and content fields. Once you're done,\nclick Save. You'll be taken back to the home screen where you can see the new\nitem you added.\n\nEdit a Note\nNow, click on a note and edit its content, then click Save. If you click on that\nnote again, you'll see that the content has been edited successfully.\n\nDelete a Note\nIf you click on a note from the home screen, you'll notice a delete button at\nthe top right of the screen.\n\nClick on the delete button and you'll be taken back to the home screen where you\ncan see your note does not exist anymore.\n\nConclusion\nThis simple note app showcases how you can connect a React Native app to Strapi.\nStrapi makes it simple to add CMS capabilities to apps using React Native. Using\na CMS like Strapi to easily manage the notes on your app allows you to also\nmanage the notes on different platforms like on the web.","html":"<p><a href=\"https://strapi.io\">Strapi</a> is a headless CMS framework that allows you to integrate CMS functionalities into any of your technical stacks. This gives you more flexibility when choosing the different components that make up your project.</p><p>One of the many frameworks you can integrate Strapi to is <a href=\"https://reactnative.dev\">React Native</a>. React Native is a cross-platform framework that allows you to write your code in JavaScript, then deploy it on Android and iOS.</p><p>In this tutorial, you'll learn how to create a Notes app with Strapi v4 and React Native. You'll be able to add notes on the Strapi backend. Then, you'll be able to view, edit, create, and delete notes in the React Native app.</p><p>You can find the code for this tutorial on <a href=\"https://github.com/shahednasser/strapi-react-native\">this GitHub repository</a>.</p><h2 id=\"setup-strapi\">Setup Strapi</h2><p>In your terminal, run the following command to install and setup Strapi:</p><pre><code class=\"language-bash\">npx create-strapi-app@latest strapi --quickstart</code></pre><p>This will create a new directory called <code>strapi</code>, and, once the installation is done, a new page will open in your default browser at the Strapi backend. It's usually at <code>localhost:1337</code>.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2022/03/Screen-Shot-2022-01-31-at-4.55.39-PM.png.jpeg\" class=\"kg-image\" alt loading=\"lazy\" width=\"880\" height=\"1026\"></figure><p>You'll need to create an admin user. Once you're done, you'll be redirected to the admin dashboard.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2022/03/Screen-Shot-2022-01-31-at-4.57.11-PM.png.jpeg\" class=\"kg-image\" alt loading=\"lazy\" width=\"880\" height=\"479\"></figure><h3 id=\"create-content-types\">Create Content-Types</h3><p>Click on <em>Content-Type Builder</em> on the sidebar. Then, click on <em>Create new collection type</em> under <em>Collection Types</em>.</p><p>In the pop-up, enter <code>Note</code> for display name. Then click continue.</p><p>You'll create 3 fields:</p><ol><li><code>title</code>: of type Text. Make sure to set it required in the Advanced Settings tab.</li><li><code>content</code>: of type Rich Text. Make sure to set it required in the Advanced Settings tab.</li><li><code>date</code>: of type Date. Make sure to select <code>datetime</code> in the Type dropdown, and set it required in the Advanced Settings tab.</li></ol><p>You should have a Note collection type with the following fields:</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2022/03/Screen-Shot-2022-01-31-at-5.01.15-PM-1.png\" class=\"kg-image\" alt loading=\"lazy\" width=\"880\" height=\"519\"></figure><p>Once you're done click <em>Save</em>.</p><h3 id=\"change-permissions\">Change Permissions</h3><p>The next step is to change permissions so that you can access the notes from React Native.</p><p>Click on <em>Settings</em> in the sidebar, then go to <em>Roles</em> under <em>Users &amp; Permissions Plugin</em>. You'll see two entries in the table. Click on the edit icon for the Public row.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2022/03/Screen-Shot-2022-01-31-at-5.01.40-PM.png.jpeg\" class=\"kg-image\" alt loading=\"lazy\" width=\"880\" height=\"500\"></figure><p>Then, scroll down. Under <em>Permissions</em>, click on <em>Note</em> to expand it, then select all permissions. Once you're done, click Save at the top right.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2022/03/Screen-Shot-2022-01-31-at-5.01.53-PM.png.jpeg\" class=\"kg-image\" alt loading=\"lazy\" width=\"880\" height=\"780\"></figure><h2 id=\"setup-react-native\">Setup React Native</h2><p>Next, you'll set up a React Native project.</p><p>First, you need to install the <a href=\"https://docs.expo.dev/workflow/expo-cli/\">Expo CLI</a> if you don't have it installed:</p><pre><code class=\"language-bash\">npm i -g expo-cli</code></pre><p>Next, run the following command to create a new React Native project:</p><pre><code class=\"language-bash\">expo init notes-app</code></pre><p>Choose <em>Blank</em> when asked about the type of project to create.</p><p>Once that is done, change to the newly created directory <code>notes-app</code> and install dependencies with NPM:</p><pre><code class=\"language-bash\">cd notes-app\nnpm i</code></pre><p>Now, you'll need to install the dependencies you'll need for this tutorial. First, start by installing some dependencies with Expo's CLI:</p><pre><code class=\"language-bash\">expo install react-native-screens react-native-safe-area-context</code></pre><p>These dependencies are necessary to add <a href=\"https://reactnavigation.org\">React Navigation</a>, which is a library that adds navigation capabilities between screens in your app.</p><p><em><a href=\"https://blog.shahednasser.com/react-native-navigation-tutorial\">Suggested Read: React Native Navigation Tutorial.</a></em></p><p>Next, install the necessary dependencies with NPM:</p><pre><code class=\"language-bash\">npm i react-native-paper @react-navigation/native @react-navigation/native-stack react-native-pell-rich-editor react-native-webview</code></pre><p>Here's what each dependency is for:</p><ol><li><code>react-native-paper</code>: <a href=\"https://callstack.github.io/react-native-paper/index.html\">React Native Paper</a> library to easily add styled-components in your app.</li><li><code>@react-navigation/native @react-navigation/native-stack</code>: More libraries for React Navigation.</li><li><code>react-native-pell-rich-editor</code>: a <a href=\"https://github.com/wxik/react-native-rich-editor\">Rich Editor</a> element for React Native.</li><li><code>react-native-webview</code>: required by <code>react-native-pell-rich-editor</code>.</li></ol><h2 id=\"create-home-screen\">Create Home Screen</h2><p>The home screen displays a list of notes with just the title and the date. It will also have a <code>+</code> button at the top right to add notes.</p><p>Create the file <code>screens/HomeScreen.js</code> with the following content:</p><pre><code class=\"language-js\">import axios from \"axios\";\nimport { useEffect, useState } from \"react\";\nimport { FlatList, View } from \"react-native\";\nimport { Caption, List, Snackbar } from \"react-native-paper\";\n\nexport default function HomeScreen ({ navigation }) {\n  const [notes, setNotes] = useState([]);\n  const [loading, setLoading] = useState(true);\n  const [error, setError] = useState('');\n\n  useEffect(() =&gt; {\n    loadNotes()\n\n    const subscribe = navigation.addListener('focus', () =&gt; {\n      loadNotes();\n    });\n\n    return subscribe;\n  }, [])\n\n  function loadNotes () {\n    axios.get('http://&lt;IP&gt;:1337/api/notes')\n      .then(({ data }) =&gt; {\n        setNotes(data.data);\n        setLoading(false);\n      })\n      .catch((e) =&gt; {\n        console.error(e);\n        setError('An error occurred, please try again later.');\n        setLoading(false);\n      });\n  }\n\n  return (\n    &lt;View&gt;\n      {!loading &amp;&amp; !notes.length &amp;&amp; &lt;Caption style={{textAlign: 'center', marginTop: 10}}&gt;You have no notes&lt;/Caption&gt;}\n      &lt;FlatList\n        data={notes}\n        renderItem={({ item }) =&gt; (\n          &lt;List.Item \n            key={item.id}\n            title={item.attributes.title}\n            description={item.attributes.date}\n            onPress={() =&gt; navigation.navigate('Editor', {\n                note: item\n            })}\n            /&gt;\n        )}      \n        refreshing={loading}\n        onRefresh={loadNotes}\n        style={{width: '100%', height: '100%'}}\n      /&gt;\n      &lt;Snackbar visible={error.length &gt; 0} onDismiss={() =&gt; setError('')}&gt;{error}&lt;/Snackbar&gt;\n    &lt;/View&gt;\n  )\n}</code></pre><p>You first create the state variable <code>notes</code> which will hold the notes when received from the Strapi backend. You use a <a href=\"https://reactnative.dev/docs/flatlist\">FlatList</a> component to display the notes. This will render each note using the <a href=\"https://callstack.github.io/react-native-paper/list-item.html\">List.Item</a> component from React Native Paper. The title of the item will be the title of the note, and the description will be the date of the note.</p><p>When the item in the list is clicked, the user will be taken to the <code>Editor</code> screen (which you'll create in the next section).</p><p>The fetching of the notes will happen in the <code>loadNotes</code> function. This function is called when the screen first opens, when the screen gains focus, and when the flat list is refreshed.</p><p>In the <code>loadNotes</code> function, you send a request to <code>http://&lt;IP&gt;:1337/api/notes</code>. Notice that to run the app on your phone, you need to use your machine's network IP. So, replace <code>&lt;IP&gt;</code> with your machine's IP.</p><p>This endpoint is Strapi's Endpoint for <a href=\"https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest-api.html#get-entries\">fetching the entries</a> of a content type. You then set the <code>notes</code> state variable to the data received from Strapi.</p><p>Next, you need to make changes to the <code>App.js</code> file to show different screens.</p><p>Open <code>App.js</code> and replace the content with the following:</p><pre><code class=\"language-js\">import { NavigationContainer } from '@react-navigation/native';\nimport { createNativeStackNavigator } from '@react-navigation/native-stack';\nimport { IconButton } from 'react-native-paper';\nimport EditorScreen from './screens/EditorScreen';\nimport HomeScreen from './screens/HomeScreen';\n\nconst Stack = createNativeStackNavigator();\n\nexport default function App() {\n  return (\n    &lt;NavigationContainer&gt;\n      &lt;Stack.Navigator&gt;\n        &lt;Stack.Screen name=\"Home\" component={HomeScreen} options={({navigation}) =&gt; ({\n          headerRight: () =&gt; (\n            &lt;IconButton icon='plus' onPress={() =&gt; navigation.navigate('Editor')} /&gt;\n          )\n        })} /&gt;\n      &lt;/Stack.Navigator&gt;\n    &lt;/NavigationContainer&gt;\n  );\n}\n</code></pre><p>Notice that the <code>Home</code> screen has a button at the top right that will take you to the <code>Editor</code> screen.</p><p>Now, let's run the app. In your terminal, run the following:</p><pre><code class=\"language-bash\">npm start</code></pre><p>This will allow you to open the app on iOS or Android. You'll need the <a href=\"https://expo.dev/client\">Expo Go</a> app on your phone. Then, on Android, open the app and scan the QR code in the terminal or the developer tool page to open the app. Alternatively, on iOS, you need to scan the QR code in your Camera app which will let you open the app in Expo Go.</p><p>When you open the app, you'll see an empty home screen.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2022/03/IMG_2484-2.PNG\" class=\"kg-image\" alt loading=\"lazy\" width=\"880\" height=\"1904\"></figure><h2 id=\"create-editor-screen\">Create Editor Screen</h2><p>Now, you'll create the editor screen which will show the user the editor with either the content filled (if editing an existing note) or an empty rich text editor.</p><p>Create <code>screens/EditorScreen.js</code> with the following content:</p><pre><code class=\"language-js\">import { useLayoutEffect, useRef, useState } from 'react';\nimport { RichEditor, RichToolbar} from \"react-native-pell-rich-editor\";\nimport { Keyboard, KeyboardAvoidingView, ScrollView, View } from 'react-native';\nimport { Button, Colors, Snackbar, Subheading, TextInput } from 'react-native-paper';\nimport axios from 'axios';\n\nexport default function EditorScreen ({ route, navigation }) {\n  const editor = useRef();\n  const [title, setTitle] = useState(route.params &amp;&amp; route.params.note ? route.params.note.attributes.title : '');\n  const [content, setContent] = useState(route.params &amp;&amp; route.params.note ? route.params.note.attributes.content : '');\n  const [error, setError] = useState('')\n\n  function saveNote () {\n    editor.current.blurContentEditor(); //lose focus for editor and close keyboard\n    Keyboard.dismiss();\n    const trimmedTitle = title.trim(),\n      trimmedContent = content.trim();\n    if (!trimmedTitle.length || !trimmedContent.length) {\n      setError('Please fill both title and content');\n      return;\n    }\n    axios({\n      method: route.params &amp;&amp; route.params.note ? 'PUT' : 'POST',\n      url: 'http://&lt;IP&gt;:1337/api/notes' + (route.params &amp;&amp; route.params.note ? '/' + route.params.note.id : ''),\n      data: {\n        data: {\n          title,\n          content,\n          date: Date.now()\n        }\n      }\n    }).then(() =&gt; {\n      //redirect back to home screen\n      navigation.goBack();\n    })\n    .catch((e) =&gt; {\n      console.error(e);\n      setError('An error occurred, please try again later')\n    })\n  }\n\n  function deleteNote () {\n    axios.delete('http://&lt;IP&gt;:1337/api/notes/' + route.params.note.id)\n      .then(() =&gt; {\n        //redirect back to home screen\n      navigation.goBack();\n      })\n      .catch((e) =&gt; {\n        console.error(e);\n        setError('An error occurred, please try again later.');\n      })\n  }\n\n  useLayoutEffect(() =&gt; {\n    navigation.setOptions({\n      headerTitle: content.length === 0 ? 'New Note' : 'Edit Note',\n      headerRight: route.params &amp;&amp; route.params.note ? () =&gt; (\n        &lt;Button color={Colors.redA100} onPress={deleteNote}&gt;Delete&lt;/Button&gt;\n      ) : () =&gt; (&lt;&gt;&lt;/&gt;)\n    });\n  }, []);\n\n  return (\n    &lt;View style={{margin: 10, flex: 1, justifyContent: 'space-between'}}&gt;\n      &lt;TextInput label=\"Title\" value={title} onChangeText={setTitle} mode=\"outlined\" /&gt;\n      &lt;Subheading&gt;Content&lt;/Subheading&gt;\n      &lt;RichToolbar\n        editor={editor}\n      /&gt;\n      &lt;ScrollView keyboardDismissMode='onDrag'&gt;\n        &lt;KeyboardAvoidingView behavior={\"position\"}\tstyle={{ flex: 1 }} keyboardVerticalOffset={250}&gt;\n          &lt;RichEditor \n            style={{ flex: 1}}\n            ref={editor} \n            onChange={setContent} \n            initialContentHTML={content} \n            placeholder='Start typing...'\n            useContainer /&gt;\n          &lt;Button onPress={saveNote} mode=\"contained\" style={{marginTop: 20}}&gt;\n            Save\n          &lt;/Button&gt;\n        &lt;/KeyboardAvoidingView&gt;\n      &lt;/ScrollView&gt;\n      &lt;Snackbar visible={error.length &gt; 0} onDismiss={() =&gt; setError('')}&gt;{error}&lt;/Snackbar&gt;\n    &lt;/View&gt;\n  )\n}</code></pre><p>In this code snippet, you create a <code>editor</code> ref variable for the Rich text editor. This is necessary for the library you're using. You also create a <code>title</code> and <code>content</code> state variables. These will be used to store the input values and will have as initial values the note's title and content if it exists.</p><p>On the screen, you show a rich text editor with a toolbar to add advanced text editing. You also add a Save button and a Delete button for existing notes.</p><h3 id=\"save-a-note\">Save a Note</h3><p>When the Save button is clicked, you check if the note exists or is new. If the note already exists, then, a <code>PUT</code> request is sent to <code>http://&lt;IP&gt;:1337/api/notes/&lt;note_id&gt;</code>, where <code>&lt;IP&gt;</code> is your machine's IP and <code>&lt;note_id&gt;</code> is the current note's ID. This Strapi endpoint is used to <a href=\"https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest-api.html#update-an-entry\">update an entry</a> in a collection.</p><p>Alternatively, if the note is new, a <code>POST</code> request is sent to <code>http://&lt;IP&gt;:1337/api/notes</code>, where <code>&lt;IP&gt;</code> is your machine's IP. This Strapi endpoint is used to <a href=\"https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest-api.html#create-an-entry\">create an entry</a>.</p><p>Both requests accept in the body of the request a <code>data</code> parameter with the entry's data. You pass the title, content, and current date.</p><h3 id=\"delete-a-note\">Delete a Note</h3><p>When the Delete Button is clicked, a <code>DELETE</code> request is sent to <code>http://&lt;IP&gt;:1337/api/notes/&lt;note_id&gt;</code>, where <code>&lt;IP&gt;</code> is your machine's IP and <code>&lt;note_id&gt;</code> is the ID of the note to delete. Remember, this is only available if the note exists.</p><p>After the note is saved or deleted, you take the user back to the home screen.</p><p>Next, you need to add the new screen to <code>App.js</code>. Add it after the <code>Home</code> screen:</p><pre><code class=\"language-js\">&lt;Stack.Screen name=\"Editor\" component={EditorScreen} /&gt;</code></pre><p>That's all, now run the app if it's not running. Try first clicking on the <code>+</code> button at the top right of the home screen. You'll see a rich text editor with a toolbar and a Save button.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2022/03/IMG_2485-2.PNG\" class=\"kg-image\" alt loading=\"lazy\" width=\"880\" height=\"1904\"></figure><h3 id=\"add-a-note\">Add a Note</h3><p>Try entering any content in both title and content fields. Once you're done, click Save. You'll be taken back to the home screen where you can see the new item you added.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2022/03/IMG_2472-2.PNG\" class=\"kg-image\" alt loading=\"lazy\" width=\"880\" height=\"1904\"></figure><h2 id=\"edit-a-note\">Edit a Note</h2><p>Now, click on a note and edit its content, then click Save. If you click on that note again, you'll see that the content has been edited successfully.</p><h2 id=\"delete-a-note-1\">Delete a Note</h2><p>If you click on a note from the home screen, you'll notice a delete button at the top right of the screen.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2022/03/IMG_2471-2.PNG\" class=\"kg-image\" alt loading=\"lazy\" width=\"880\" height=\"1904\"></figure><p>Click on the delete button and you'll be taken back to the home screen where you can see your note does not exist anymore.</p><h2 id=\"conclusion\">Conclusion</h2><p>This simple note app showcases how you can connect a React Native app to Strapi. Strapi makes it simple to add CMS capabilities to apps using React Native. Using a CMS like Strapi to easily manage the notes on your app allows you to also manage the notes on different platforms like on the web.</p>","url":"https://backend.shahednasser.com/how-to-create-notes-app-with-strapi-v4-and-react-native/","canonical_url":null,"uuid":"3fbecae1-e391-4a06-8008-26a0f7f85727","codeinjection_foot":null,"codeinjection_head":null,"codeinjection_styles":null,"comment_id":"61f9452160a9ab05cc5e689a","reading_time":9,"send_email_when_published":null,"email_subject":null,"childHtmlRehype":{"html":"<p><a href=\"https://strapi.io\">Strapi</a> is a headless CMS framework that allows you to integrate CMS functionalities into any of your technical stacks. This gives you more flexibility when choosing the different components that make up your project.</p><p>One of the many frameworks you can integrate Strapi to is <a href=\"https://reactnative.dev\">React Native</a>. React Native is a cross-platform framework that allows you to write your code in JavaScript, then deploy it on Android and iOS.</p><p>In this tutorial, you'll learn how to create a Notes app with Strapi v4 and React Native. You'll be able to add notes on the Strapi backend. Then, you'll be able to view, edit, create, and delete notes in the React Native app.</p><p>You can find the code for this tutorial on <a href=\"https://github.com/shahednasser/strapi-react-native\">this GitHub repository</a>.</p><h2 id=\"setup-strapi\">Setup Strapi</h2><p>In your terminal, run the following command to install and setup Strapi:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">npx create-strapi-app@latest strapi --quickstart</code></pre></div><p>This will create a new directory called <code class=\"language-text\">strapi</code>, and, once the installation is done, a new page will open in your default browser at the Strapi backend. It's usually at <code class=\"language-text\">localhost:1337</code>.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2022/03/Screen-Shot-2022-01-31-at-4.55.39-PM.png.jpeg\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"880\" height=\"1026\"></figure><p>You'll need to create an admin user. Once you're done, you'll be redirected to the admin dashboard.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2022/03/Screen-Shot-2022-01-31-at-4.57.11-PM.png.jpeg\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"880\" height=\"479\"></figure><h3 id=\"create-content-types\">Create Content-Types</h3><p>Click on <em>Content-Type Builder</em> on the sidebar. Then, click on <em>Create new collection type</em> under <em>Collection Types</em>.</p><p>In the pop-up, enter <code class=\"language-text\">Note</code> for display name. Then click continue.</p><p>You'll create 3 fields:</p><ol><li><code class=\"language-text\">title</code>: of type Text. Make sure to set it required in the Advanced Settings tab.</li><li><code class=\"language-text\">content</code>: of type Rich Text. Make sure to set it required in the Advanced Settings tab.</li><li><code class=\"language-text\">date</code>: of type Date. Make sure to select <code class=\"language-text\">datetime</code> in the Type dropdown, and set it required in the Advanced Settings tab.</li></ol><p>You should have a Note collection type with the following fields:</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2022/03/Screen-Shot-2022-01-31-at-5.01.15-PM-1.png\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"880\" height=\"519\"></figure><p>Once you're done click <em>Save</em>.</p><h3 id=\"change-permissions\">Change Permissions</h3><p>The next step is to change permissions so that you can access the notes from React Native.</p><p>Click on <em>Settings</em> in the sidebar, then go to <em>Roles</em> under <em>Users &#x26; Permissions Plugin</em>. You'll see two entries in the table. Click on the edit icon for the Public row.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2022/03/Screen-Shot-2022-01-31-at-5.01.40-PM.png.jpeg\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"880\" height=\"500\"></figure><p>Then, scroll down. Under <em>Permissions</em>, click on <em>Note</em> to expand it, then select all permissions. Once you're done, click Save at the top right.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2022/03/Screen-Shot-2022-01-31-at-5.01.53-PM.png.jpeg\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"880\" height=\"780\"></figure><h2 id=\"setup-react-native\">Setup React Native</h2><p>Next, you'll set up a React Native project.</p><p>First, you need to install the <a href=\"https://docs.expo.dev/workflow/expo-cli/\">Expo CLI</a> if you don't have it installed:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">npm</span> i -g expo-cli</code></pre></div><p>Next, run the following command to create a new React Native project:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">expo init notes-app</code></pre></div><p>Choose <em>Blank</em> when asked about the type of project to create.</p><p>Once that is done, change to the newly created directory <code class=\"language-text\">notes-app</code> and install dependencies with NPM:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token builtin class-name\">cd</span> notes-app\n<span class=\"token function\">npm</span> i</code></pre></div><p>Now, you'll need to install the dependencies you'll need for this tutorial. First, start by installing some dependencies with Expo's CLI:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">expo <span class=\"token function\">install</span> react-native-screens react-native-safe-area-context</code></pre></div><p>These dependencies are necessary to add <a href=\"https://reactnavigation.org\">React Navigation</a>, which is a library that adds navigation capabilities between screens in your app.</p><p><em><a href=\"https://blog.shahednasser.com/react-native-navigation-tutorial\">Suggested Read: React Native Navigation Tutorial.</a></em></p><p>Next, install the necessary dependencies with NPM:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">npm</span> i react-native-paper @react-navigation/native @react-navigation/native-stack react-native-pell-rich-editor react-native-webview</code></pre></div><p>Here's what each dependency is for:</p><ol><li><code class=\"language-text\">react-native-paper</code>: <a href=\"https://callstack.github.io/react-native-paper/index.html\">React Native Paper</a> library to easily add styled-components in your app.</li><li><code class=\"language-text\">@react-navigation/native @react-navigation/native-stack</code>: More libraries for React Navigation.</li><li><code class=\"language-text\">react-native-pell-rich-editor</code>: a <a href=\"https://github.com/wxik/react-native-rich-editor\">Rich Editor</a> element for React Native.</li><li><code class=\"language-text\">react-native-webview</code>: required by <code class=\"language-text\">react-native-pell-rich-editor</code>.</li></ol><h2 id=\"create-home-screen\">Create Home Screen</h2><p>The home screen displays a list of notes with just the title and the date. It will also have a <code class=\"language-text\">+</code> button at the top right to add notes.</p><p>Create the file <code class=\"language-text\">screens/HomeScreen.js</code> with the following content:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">import</span> axios <span class=\"token keyword\">from</span> <span class=\"token string\">\"axios\"</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> useEffect<span class=\"token punctuation\">,</span> useState <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">\"react\"</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> FlatList<span class=\"token punctuation\">,</span> View <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">\"react-native\"</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> Caption<span class=\"token punctuation\">,</span> List<span class=\"token punctuation\">,</span> Snackbar <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">\"react-native-paper\"</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">export</span> <span class=\"token keyword\">default</span> <span class=\"token keyword\">function</span> <span class=\"token function\">HomeScreen</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\"><span class=\"token punctuation\">{</span> navigation <span class=\"token punctuation\">}</span></span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token keyword\">const</span> <span class=\"token punctuation\">[</span>notes<span class=\"token punctuation\">,</span> setNotes<span class=\"token punctuation\">]</span> <span class=\"token operator\">=</span> <span class=\"token function\">useState</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token keyword\">const</span> <span class=\"token punctuation\">[</span>loading<span class=\"token punctuation\">,</span> setLoading<span class=\"token punctuation\">]</span> <span class=\"token operator\">=</span> <span class=\"token function\">useState</span><span class=\"token punctuation\">(</span><span class=\"token boolean\">true</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token keyword\">const</span> <span class=\"token punctuation\">[</span>error<span class=\"token punctuation\">,</span> setError<span class=\"token punctuation\">]</span> <span class=\"token operator\">=</span> <span class=\"token function\">useState</span><span class=\"token punctuation\">(</span><span class=\"token string\">''</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n  <span class=\"token function\">useEffect</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\n    <span class=\"token function\">loadNotes</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span>\n\n    <span class=\"token keyword\">const</span> subscribe <span class=\"token operator\">=</span> navigation<span class=\"token punctuation\">.</span><span class=\"token function\">addListener</span><span class=\"token punctuation\">(</span><span class=\"token string\">'focus'</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\n      <span class=\"token function\">loadNotes</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n    <span class=\"token keyword\">return</span> subscribe<span class=\"token punctuation\">;</span>\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">)</span>\n\n  <span class=\"token keyword\">function</span> <span class=\"token function\">loadNotes</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n    axios<span class=\"token punctuation\">.</span><span class=\"token function\">get</span><span class=\"token punctuation\">(</span><span class=\"token string\">'http://&#x3C;IP>:1337/api/notes'</span><span class=\"token punctuation\">)</span>\n      <span class=\"token punctuation\">.</span><span class=\"token function\">then</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token parameter\"><span class=\"token punctuation\">{</span> data <span class=\"token punctuation\">}</span></span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\n        <span class=\"token function\">setNotes</span><span class=\"token punctuation\">(</span>data<span class=\"token punctuation\">.</span>data<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n        <span class=\"token function\">setLoading</span><span class=\"token punctuation\">(</span><span class=\"token boolean\">false</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n      <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span>\n      <span class=\"token punctuation\">.</span><span class=\"token function\">catch</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">e</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\n        console<span class=\"token punctuation\">.</span><span class=\"token function\">error</span><span class=\"token punctuation\">(</span>e<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n        <span class=\"token function\">setError</span><span class=\"token punctuation\">(</span><span class=\"token string\">'An error occurred, please try again later.'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n        <span class=\"token function\">setLoading</span><span class=\"token punctuation\">(</span><span class=\"token boolean\">false</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n      <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token punctuation\">}</span>\n\n  <span class=\"token keyword\">return</span> <span class=\"token punctuation\">(</span>\n    <span class=\"token operator\">&#x3C;</span>View<span class=\"token operator\">></span>\n      <span class=\"token punctuation\">{</span><span class=\"token operator\">!</span>loading <span class=\"token operator\">&#x26;&#x26;</span> <span class=\"token operator\">!</span>notes<span class=\"token punctuation\">.</span>length <span class=\"token operator\">&#x26;&#x26;</span> <span class=\"token operator\">&#x3C;</span>Caption style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">{</span><span class=\"token literal-property property\">textAlign</span><span class=\"token operator\">:</span> <span class=\"token string\">'center'</span><span class=\"token punctuation\">,</span> <span class=\"token literal-property property\">marginTop</span><span class=\"token operator\">:</span> <span class=\"token number\">10</span><span class=\"token punctuation\">}</span><span class=\"token punctuation\">}</span><span class=\"token operator\">></span>You have no notes<span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Caption<span class=\"token operator\">></span><span class=\"token punctuation\">}</span>\n      <span class=\"token operator\">&#x3C;</span>FlatList\n        data<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>notes<span class=\"token punctuation\">}</span>\n        renderItem<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">(</span><span class=\"token parameter\"><span class=\"token punctuation\">{</span> item <span class=\"token punctuation\">}</span></span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">(</span>\n          <span class=\"token operator\">&#x3C;</span>List<span class=\"token punctuation\">.</span>Item \n            key<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>item<span class=\"token punctuation\">.</span>id<span class=\"token punctuation\">}</span>\n            title<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>item<span class=\"token punctuation\">.</span>attributes<span class=\"token punctuation\">.</span>title<span class=\"token punctuation\">}</span>\n            description<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>item<span class=\"token punctuation\">.</span>attributes<span class=\"token punctuation\">.</span>date<span class=\"token punctuation\">}</span>\n            onPress<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> navigation<span class=\"token punctuation\">.</span><span class=\"token function\">navigate</span><span class=\"token punctuation\">(</span><span class=\"token string\">'Editor'</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">{</span>\n                <span class=\"token literal-property property\">note</span><span class=\"token operator\">:</span> item\n            <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">}</span>\n            <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n        <span class=\"token punctuation\">)</span><span class=\"token punctuation\">}</span>      \n        refreshing<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>loading<span class=\"token punctuation\">}</span>\n        onRefresh<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>loadNotes<span class=\"token punctuation\">}</span>\n        style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">{</span><span class=\"token literal-property property\">width</span><span class=\"token operator\">:</span> <span class=\"token string\">'100%'</span><span class=\"token punctuation\">,</span> <span class=\"token literal-property property\">height</span><span class=\"token operator\">:</span> <span class=\"token string\">'100%'</span><span class=\"token punctuation\">}</span><span class=\"token punctuation\">}</span>\n      <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span>Snackbar visible<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>error<span class=\"token punctuation\">.</span>length <span class=\"token operator\">></span> <span class=\"token number\">0</span><span class=\"token punctuation\">}</span> onDismiss<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token function\">setError</span><span class=\"token punctuation\">(</span><span class=\"token string\">''</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">}</span><span class=\"token operator\">></span><span class=\"token punctuation\">{</span>error<span class=\"token punctuation\">}</span><span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Snackbar<span class=\"token operator\">></span>\n    <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>View<span class=\"token operator\">></span>\n  <span class=\"token punctuation\">)</span>\n<span class=\"token punctuation\">}</span></code></pre></div><p>You first create the state variable <code class=\"language-text\">notes</code> which will hold the notes when received from the Strapi backend. You use a <a href=\"https://reactnative.dev/docs/flatlist\">FlatList</a> component to display the notes. This will render each note using the <a href=\"https://callstack.github.io/react-native-paper/list-item.html\">List.Item</a> component from React Native Paper. The title of the item will be the title of the note, and the description will be the date of the note.</p><p>When the item in the list is clicked, the user will be taken to the <code class=\"language-text\">Editor</code> screen (which you'll create in the next section).</p><p>The fetching of the notes will happen in the <code class=\"language-text\">loadNotes</code> function. This function is called when the screen first opens, when the screen gains focus, and when the flat list is refreshed.</p><p>In the <code class=\"language-text\">loadNotes</code> function, you send a request to <code class=\"language-text\">http://&#x3C;IP>:1337/api/notes</code>. Notice that to run the app on your phone, you need to use your machine's network IP. So, replace <code class=\"language-text\">&#x3C;IP></code> with your machine's IP.</p><p>This endpoint is Strapi's Endpoint for <a href=\"https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest-api.html#get-entries\">fetching the entries</a> of a content type. You then set the <code class=\"language-text\">notes</code> state variable to the data received from Strapi.</p><p>Next, you need to make changes to the <code class=\"language-text\">App.js</code> file to show different screens.</p><p>Open <code class=\"language-text\">App.js</code> and replace the content with the following:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> NavigationContainer <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'@react-navigation/native'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> createNativeStackNavigator <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'@react-navigation/native-stack'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> IconButton <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native-paper'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> EditorScreen <span class=\"token keyword\">from</span> <span class=\"token string\">'./screens/EditorScreen'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> HomeScreen <span class=\"token keyword\">from</span> <span class=\"token string\">'./screens/HomeScreen'</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">const</span> Stack <span class=\"token operator\">=</span> <span class=\"token function\">createNativeStackNavigator</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">export</span> <span class=\"token keyword\">default</span> <span class=\"token keyword\">function</span> <span class=\"token function\">App</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token keyword\">return</span> <span class=\"token punctuation\">(</span>\n    <span class=\"token operator\">&#x3C;</span>NavigationContainer<span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span>Stack<span class=\"token punctuation\">.</span>Navigator<span class=\"token operator\">></span>\n        <span class=\"token operator\">&#x3C;</span>Stack<span class=\"token punctuation\">.</span>Screen name<span class=\"token operator\">=</span><span class=\"token string\">\"Home\"</span> component<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>HomeScreen<span class=\"token punctuation\">}</span> options<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">(</span><span class=\"token parameter\"><span class=\"token punctuation\">{</span>navigation<span class=\"token punctuation\">}</span></span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\n          <span class=\"token function-variable function\">headerRight</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">(</span>\n            <span class=\"token operator\">&#x3C;</span>IconButton icon<span class=\"token operator\">=</span><span class=\"token string\">'plus'</span> onPress<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> navigation<span class=\"token punctuation\">.</span><span class=\"token function\">navigate</span><span class=\"token punctuation\">(</span><span class=\"token string\">'Editor'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">}</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n          <span class=\"token punctuation\">)</span>\n        <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">}</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Stack<span class=\"token punctuation\">.</span>Navigator<span class=\"token operator\">></span>\n    <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>NavigationContainer<span class=\"token operator\">></span>\n  <span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span>\n</code></pre></div><p>Notice that the <code class=\"language-text\">Home</code> screen has a button at the top right that will take you to the <code class=\"language-text\">Editor</code> screen.</p><p>Now, let's run the app. In your terminal, run the following:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">npm</span> start</code></pre></div><p>This will allow you to open the app on iOS or Android. You'll need the <a href=\"https://expo.dev/client\">Expo Go</a> app on your phone. Then, on Android, open the app and scan the QR code in the terminal or the developer tool page to open the app. Alternatively, on iOS, you need to scan the QR code in your Camera app which will let you open the app in Expo Go.</p><p>When you open the app, you'll see an empty home screen.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2022/03/IMG_2484-2.PNG\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"880\" height=\"1904\"></figure><h2 id=\"create-editor-screen\">Create Editor Screen</h2><p>Now, you'll create the editor screen which will show the user the editor with either the content filled (if editing an existing note) or an empty rich text editor.</p><p>Create <code class=\"language-text\">screens/EditorScreen.js</code> with the following content:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> useLayoutEffect<span class=\"token punctuation\">,</span> useRef<span class=\"token punctuation\">,</span> useState <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> RichEditor<span class=\"token punctuation\">,</span> RichToolbar<span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">\"react-native-pell-rich-editor\"</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> Keyboard<span class=\"token punctuation\">,</span> KeyboardAvoidingView<span class=\"token punctuation\">,</span> ScrollView<span class=\"token punctuation\">,</span> View <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> Button<span class=\"token punctuation\">,</span> Colors<span class=\"token punctuation\">,</span> Snackbar<span class=\"token punctuation\">,</span> Subheading<span class=\"token punctuation\">,</span> TextInput <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native-paper'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> axios <span class=\"token keyword\">from</span> <span class=\"token string\">'axios'</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">export</span> <span class=\"token keyword\">default</span> <span class=\"token keyword\">function</span> <span class=\"token function\">EditorScreen</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\"><span class=\"token punctuation\">{</span> route<span class=\"token punctuation\">,</span> navigation <span class=\"token punctuation\">}</span></span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token keyword\">const</span> editor <span class=\"token operator\">=</span> <span class=\"token function\">useRef</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token keyword\">const</span> <span class=\"token punctuation\">[</span>title<span class=\"token punctuation\">,</span> setTitle<span class=\"token punctuation\">]</span> <span class=\"token operator\">=</span> <span class=\"token function\">useState</span><span class=\"token punctuation\">(</span>route<span class=\"token punctuation\">.</span>params <span class=\"token operator\">&#x26;&#x26;</span> route<span class=\"token punctuation\">.</span>params<span class=\"token punctuation\">.</span>note <span class=\"token operator\">?</span> route<span class=\"token punctuation\">.</span>params<span class=\"token punctuation\">.</span>note<span class=\"token punctuation\">.</span>attributes<span class=\"token punctuation\">.</span>title <span class=\"token operator\">:</span> <span class=\"token string\">''</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token keyword\">const</span> <span class=\"token punctuation\">[</span>content<span class=\"token punctuation\">,</span> setContent<span class=\"token punctuation\">]</span> <span class=\"token operator\">=</span> <span class=\"token function\">useState</span><span class=\"token punctuation\">(</span>route<span class=\"token punctuation\">.</span>params <span class=\"token operator\">&#x26;&#x26;</span> route<span class=\"token punctuation\">.</span>params<span class=\"token punctuation\">.</span>note <span class=\"token operator\">?</span> route<span class=\"token punctuation\">.</span>params<span class=\"token punctuation\">.</span>note<span class=\"token punctuation\">.</span>attributes<span class=\"token punctuation\">.</span>content <span class=\"token operator\">:</span> <span class=\"token string\">''</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token keyword\">const</span> <span class=\"token punctuation\">[</span>error<span class=\"token punctuation\">,</span> setError<span class=\"token punctuation\">]</span> <span class=\"token operator\">=</span> <span class=\"token function\">useState</span><span class=\"token punctuation\">(</span><span class=\"token string\">''</span><span class=\"token punctuation\">)</span>\n\n  <span class=\"token keyword\">function</span> <span class=\"token function\">saveNote</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n    editor<span class=\"token punctuation\">.</span>current<span class=\"token punctuation\">.</span><span class=\"token function\">blurContentEditor</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> <span class=\"token comment\">//lose focus for editor and close keyboard</span>\n    Keyboard<span class=\"token punctuation\">.</span><span class=\"token function\">dismiss</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n    <span class=\"token keyword\">const</span> trimmedTitle <span class=\"token operator\">=</span> title<span class=\"token punctuation\">.</span><span class=\"token function\">trim</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span>\n      trimmedContent <span class=\"token operator\">=</span> content<span class=\"token punctuation\">.</span><span class=\"token function\">trim</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n    <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span><span class=\"token operator\">!</span>trimmedTitle<span class=\"token punctuation\">.</span>length <span class=\"token operator\">||</span> <span class=\"token operator\">!</span>trimmedContent<span class=\"token punctuation\">.</span>length<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n      <span class=\"token function\">setError</span><span class=\"token punctuation\">(</span><span class=\"token string\">'Please fill both title and content'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n      <span class=\"token keyword\">return</span><span class=\"token punctuation\">;</span>\n    <span class=\"token punctuation\">}</span>\n    <span class=\"token function\">axios</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\n      <span class=\"token literal-property property\">method</span><span class=\"token operator\">:</span> route<span class=\"token punctuation\">.</span>params <span class=\"token operator\">&#x26;&#x26;</span> route<span class=\"token punctuation\">.</span>params<span class=\"token punctuation\">.</span>note <span class=\"token operator\">?</span> <span class=\"token string\">'PUT'</span> <span class=\"token operator\">:</span> <span class=\"token string\">'POST'</span><span class=\"token punctuation\">,</span>\n      <span class=\"token literal-property property\">url</span><span class=\"token operator\">:</span> <span class=\"token string\">'http://&#x3C;IP>:1337/api/notes'</span> <span class=\"token operator\">+</span> <span class=\"token punctuation\">(</span>route<span class=\"token punctuation\">.</span>params <span class=\"token operator\">&#x26;&#x26;</span> route<span class=\"token punctuation\">.</span>params<span class=\"token punctuation\">.</span>note <span class=\"token operator\">?</span> <span class=\"token string\">'/'</span> <span class=\"token operator\">+</span> route<span class=\"token punctuation\">.</span>params<span class=\"token punctuation\">.</span>note<span class=\"token punctuation\">.</span>id <span class=\"token operator\">:</span> <span class=\"token string\">''</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span>\n      <span class=\"token literal-property property\">data</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n        <span class=\"token literal-property property\">data</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n          title<span class=\"token punctuation\">,</span>\n          content<span class=\"token punctuation\">,</span>\n          <span class=\"token literal-property property\">date</span><span class=\"token operator\">:</span> Date<span class=\"token punctuation\">.</span><span class=\"token function\">now</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span>\n        <span class=\"token punctuation\">}</span>\n      <span class=\"token punctuation\">}</span>\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">then</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\n      <span class=\"token comment\">//redirect back to home screen</span>\n      navigation<span class=\"token punctuation\">.</span><span class=\"token function\">goBack</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span>\n    <span class=\"token punctuation\">.</span><span class=\"token function\">catch</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">e</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\n      console<span class=\"token punctuation\">.</span><span class=\"token function\">error</span><span class=\"token punctuation\">(</span>e<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n      <span class=\"token function\">setError</span><span class=\"token punctuation\">(</span><span class=\"token string\">'An error occurred, please try again later'</span><span class=\"token punctuation\">)</span>\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span>\n  <span class=\"token punctuation\">}</span>\n\n  <span class=\"token keyword\">function</span> <span class=\"token function\">deleteNote</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n    axios<span class=\"token punctuation\">.</span><span class=\"token function\">delete</span><span class=\"token punctuation\">(</span><span class=\"token string\">'http://&#x3C;IP>:1337/api/notes/'</span> <span class=\"token operator\">+</span> route<span class=\"token punctuation\">.</span>params<span class=\"token punctuation\">.</span>note<span class=\"token punctuation\">.</span>id<span class=\"token punctuation\">)</span>\n      <span class=\"token punctuation\">.</span><span class=\"token function\">then</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\n        <span class=\"token comment\">//redirect back to home screen</span>\n      navigation<span class=\"token punctuation\">.</span><span class=\"token function\">goBack</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n      <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span>\n      <span class=\"token punctuation\">.</span><span class=\"token function\">catch</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">e</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\n        console<span class=\"token punctuation\">.</span><span class=\"token function\">error</span><span class=\"token punctuation\">(</span>e<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n        <span class=\"token function\">setError</span><span class=\"token punctuation\">(</span><span class=\"token string\">'An error occurred, please try again later.'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n      <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span>\n  <span class=\"token punctuation\">}</span>\n\n  <span class=\"token function\">useLayoutEffect</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\n    navigation<span class=\"token punctuation\">.</span><span class=\"token function\">setOptions</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\n      <span class=\"token literal-property property\">headerTitle</span><span class=\"token operator\">:</span> content<span class=\"token punctuation\">.</span>length <span class=\"token operator\">===</span> <span class=\"token number\">0</span> <span class=\"token operator\">?</span> <span class=\"token string\">'New Note'</span> <span class=\"token operator\">:</span> <span class=\"token string\">'Edit Note'</span><span class=\"token punctuation\">,</span>\n      <span class=\"token literal-property property\">headerRight</span><span class=\"token operator\">:</span> route<span class=\"token punctuation\">.</span>params <span class=\"token operator\">&#x26;&#x26;</span> route<span class=\"token punctuation\">.</span>params<span class=\"token punctuation\">.</span>note <span class=\"token operator\">?</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">(</span>\n        <span class=\"token operator\">&#x3C;</span>Button color<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>Colors<span class=\"token punctuation\">.</span>redA100<span class=\"token punctuation\">}</span> onPress<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>deleteNote<span class=\"token punctuation\">}</span><span class=\"token operator\">></span>Delete<span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Button<span class=\"token operator\">></span>\n      <span class=\"token punctuation\">)</span> <span class=\"token operator\">:</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">(</span><span class=\"token operator\">&#x3C;</span><span class=\"token operator\">></span><span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span><span class=\"token operator\">></span><span class=\"token punctuation\">)</span>\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n  <span class=\"token keyword\">return</span> <span class=\"token punctuation\">(</span>\n    <span class=\"token operator\">&#x3C;</span>View style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">{</span><span class=\"token literal-property property\">margin</span><span class=\"token operator\">:</span> <span class=\"token number\">10</span><span class=\"token punctuation\">,</span> <span class=\"token literal-property property\">flex</span><span class=\"token operator\">:</span> <span class=\"token number\">1</span><span class=\"token punctuation\">,</span> <span class=\"token literal-property property\">justifyContent</span><span class=\"token operator\">:</span> <span class=\"token string\">'space-between'</span><span class=\"token punctuation\">}</span><span class=\"token punctuation\">}</span><span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span>TextInput label<span class=\"token operator\">=</span><span class=\"token string\">\"Title\"</span> value<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>title<span class=\"token punctuation\">}</span> onChangeText<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>setTitle<span class=\"token punctuation\">}</span> mode<span class=\"token operator\">=</span><span class=\"token string\">\"outlined\"</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span>Subheading<span class=\"token operator\">></span>Content<span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Subheading<span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span>RichToolbar\n        editor<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>editor<span class=\"token punctuation\">}</span>\n      <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span>ScrollView keyboardDismissMode<span class=\"token operator\">=</span><span class=\"token string\">'onDrag'</span><span class=\"token operator\">></span>\n        <span class=\"token operator\">&#x3C;</span>KeyboardAvoidingView behavior<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token string\">\"position\"</span><span class=\"token punctuation\">}</span>\tstyle<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">{</span> <span class=\"token literal-property property\">flex</span><span class=\"token operator\">:</span> <span class=\"token number\">1</span> <span class=\"token punctuation\">}</span><span class=\"token punctuation\">}</span> keyboardVerticalOffset<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token number\">250</span><span class=\"token punctuation\">}</span><span class=\"token operator\">></span>\n          <span class=\"token operator\">&#x3C;</span>RichEditor \n            style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">{</span> <span class=\"token literal-property property\">flex</span><span class=\"token operator\">:</span> <span class=\"token number\">1</span><span class=\"token punctuation\">}</span><span class=\"token punctuation\">}</span>\n            ref<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>editor<span class=\"token punctuation\">}</span> \n            onChange<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>setContent<span class=\"token punctuation\">}</span> \n            initialContentHTML<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>content<span class=\"token punctuation\">}</span> \n            placeholder<span class=\"token operator\">=</span><span class=\"token string\">'Start typing...'</span>\n            useContainer <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n          <span class=\"token operator\">&#x3C;</span>Button onPress<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>saveNote<span class=\"token punctuation\">}</span> mode<span class=\"token operator\">=</span><span class=\"token string\">\"contained\"</span> style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">{</span><span class=\"token literal-property property\">marginTop</span><span class=\"token operator\">:</span> <span class=\"token number\">20</span><span class=\"token punctuation\">}</span><span class=\"token punctuation\">}</span><span class=\"token operator\">></span>\n            Save\n          <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Button<span class=\"token operator\">></span>\n        <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>KeyboardAvoidingView<span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>ScrollView<span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span>Snackbar visible<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>error<span class=\"token punctuation\">.</span>length <span class=\"token operator\">></span> <span class=\"token number\">0</span><span class=\"token punctuation\">}</span> onDismiss<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token function\">setError</span><span class=\"token punctuation\">(</span><span class=\"token string\">''</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">}</span><span class=\"token operator\">></span><span class=\"token punctuation\">{</span>error<span class=\"token punctuation\">}</span><span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Snackbar<span class=\"token operator\">></span>\n    <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>View<span class=\"token operator\">></span>\n  <span class=\"token punctuation\">)</span>\n<span class=\"token punctuation\">}</span></code></pre></div><p>In this code snippet, you create a <code class=\"language-text\">editor</code> ref variable for the Rich text editor. This is necessary for the library you're using. You also create a <code class=\"language-text\">title</code> and <code class=\"language-text\">content</code> state variables. These will be used to store the input values and will have as initial values the note's title and content if it exists.</p><p>On the screen, you show a rich text editor with a toolbar to add advanced text editing. You also add a Save button and a Delete button for existing notes.</p><h3 id=\"save-a-note\">Save a Note</h3><p>When the Save button is clicked, you check if the note exists or is new. If the note already exists, then, a <code class=\"language-text\">PUT</code> request is sent to <code class=\"language-text\">http://&#x3C;IP>:1337/api/notes/&#x3C;note_id></code>, where <code class=\"language-text\">&#x3C;IP></code> is your machine's IP and <code class=\"language-text\">&#x3C;note_id></code> is the current note's ID. This Strapi endpoint is used to <a href=\"https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest-api.html#update-an-entry\">update an entry</a> in a collection.</p><p>Alternatively, if the note is new, a <code class=\"language-text\">POST</code> request is sent to <code class=\"language-text\">http://&#x3C;IP>:1337/api/notes</code>, where <code class=\"language-text\">&#x3C;IP></code> is your machine's IP. This Strapi endpoint is used to <a href=\"https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest-api.html#create-an-entry\">create an entry</a>.</p><p>Both requests accept in the body of the request a <code class=\"language-text\">data</code> parameter with the entry's data. You pass the title, content, and current date.</p><h3 id=\"delete-a-note\">Delete a Note</h3><p>When the Delete Button is clicked, a <code class=\"language-text\">DELETE</code> request is sent to <code class=\"language-text\">http://&#x3C;IP>:1337/api/notes/&#x3C;note_id></code>, where <code class=\"language-text\">&#x3C;IP></code> is your machine's IP and <code class=\"language-text\">&#x3C;note_id></code> is the ID of the note to delete. Remember, this is only available if the note exists.</p><p>After the note is saved or deleted, you take the user back to the home screen.</p><p>Next, you need to add the new screen to <code class=\"language-text\">App.js</code>. Add it after the <code class=\"language-text\">Home</code> screen:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token operator\">&#x3C;</span>Stack<span class=\"token punctuation\">.</span>Screen name<span class=\"token operator\">=</span><span class=\"token string\">\"Editor\"</span> component<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>EditorScreen<span class=\"token punctuation\">}</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span></code></pre></div><p>That's all, now run the app if it's not running. Try first clicking on the <code class=\"language-text\">+</code> button at the top right of the home screen. You'll see a rich text editor with a toolbar and a Save button.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2022/03/IMG_2485-2.PNG\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"880\" height=\"1904\"></figure><h3 id=\"add-a-note\">Add a Note</h3><p>Try entering any content in both title and content fields. Once you're done, click Save. You'll be taken back to the home screen where you can see the new item you added.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2022/03/IMG_2472-2.PNG\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"880\" height=\"1904\"></figure><h2 id=\"edit-a-note\">Edit a Note</h2><p>Now, click on a note and edit its content, then click Save. If you click on that note again, you'll see that the content has been edited successfully.</p><h2 id=\"delete-a-note-1\">Delete a Note</h2><p>If you click on a note from the home screen, you'll notice a delete button at the top right of the screen.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2022/03/IMG_2471-2.PNG\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"880\" height=\"1904\"></figure><p>Click on the delete button and you'll be taken back to the home screen where you can see your note does not exist anymore.</p><h2 id=\"conclusion\">Conclusion</h2><p>This simple note app showcases how you can connect a React Native app to Strapi. Strapi makes it simple to add CMS capabilities to apps using React Native. Using a CMS like Strapi to easily manage the notes on your app allows you to also manage the notes on different platforms like on the web.</p>","htmlAst":{"type":"root","children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"https://strapi.io"},"children":[{"type":"text","value":"Strapi"}]},{"type":"text","value":" is a headless CMS framework that allows you to integrate CMS functionalities into any of your technical stacks. This gives you more flexibility when choosing the different components that make up your project."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"One of the many frameworks you can integrate Strapi to is "},{"type":"element","tagName":"a","properties":{"href":"https://reactnative.dev"},"children":[{"type":"text","value":"React Native"}]},{"type":"text","value":". React Native is a cross-platform framework that allows you to write your code in JavaScript, then deploy it on Android and iOS."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In this tutorial, you'll learn how to create a Notes app with Strapi v4 and React Native. You'll be able to add notes on the Strapi backend. Then, you'll be able to view, edit, create, and delete notes in the React Native app."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can find the code for this tutorial on "},{"type":"element","tagName":"a","properties":{"href":"https://github.com/shahednasser/strapi-react-native"},"children":[{"type":"text","value":"this GitHub repository"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"h2","properties":{"id":"setup-strapi"},"children":[{"type":"text","value":"Setup Strapi"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In your terminal, run the following command to install and setup Strapi:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"npx create-strapi-app@latest strapi --quickstart"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This will create a new directory called "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"strapi"}]},{"type":"text","value":", and, once the installation is done, a new page will open in your default browser at the Strapi backend. It's usually at "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"localhost:1337"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2022/03/Screen-Shot-2022-01-31-at-4.55.39-PM.png.jpeg","className":["kg-image"],"alt":"","loading":"lazy","width":880,"height":1026},"children":[]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You'll need to create an admin user. Once you're done, you'll be redirected to the admin dashboard."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2022/03/Screen-Shot-2022-01-31-at-4.57.11-PM.png.jpeg","className":["kg-image"],"alt":"","loading":"lazy","width":880,"height":479},"children":[]}]},{"type":"element","tagName":"h3","properties":{"id":"create-content-types"},"children":[{"type":"text","value":"Create Content-Types"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Click on "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"Content-Type Builder"}]},{"type":"text","value":" on the sidebar. Then, click on "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"Create new collection type"}]},{"type":"text","value":" under "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"Collection Types"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In the pop-up, enter "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Note"}]},{"type":"text","value":" for display name. Then click continue."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You'll create 3 fields:"}]},{"type":"element","tagName":"ol","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"title"}]},{"type":"text","value":": of type Text. Make sure to set it required in the Advanced Settings tab."}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"content"}]},{"type":"text","value":": of type Rich Text. Make sure to set it required in the Advanced Settings tab."}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"date"}]},{"type":"text","value":": of type Date. Make sure to select "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"datetime"}]},{"type":"text","value":" in the Type dropdown, and set it required in the Advanced Settings tab."}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You should have a Note collection type with the following fields:"}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2022/03/Screen-Shot-2022-01-31-at-5.01.15-PM-1.png","className":["kg-image"],"alt":"","loading":"lazy","width":880,"height":519},"children":[]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Once you're done click "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"Save"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"h3","properties":{"id":"change-permissions"},"children":[{"type":"text","value":"Change Permissions"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The next step is to change permissions so that you can access the notes from React Native."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Click on "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"Settings"}]},{"type":"text","value":" in the sidebar, then go to "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"Roles"}]},{"type":"text","value":" under "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"Users & Permissions Plugin"}]},{"type":"text","value":". You'll see two entries in the table. Click on the edit icon for the Public row."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2022/03/Screen-Shot-2022-01-31-at-5.01.40-PM.png.jpeg","className":["kg-image"],"alt":"","loading":"lazy","width":880,"height":500},"children":[]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Then, scroll down. Under "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"Permissions"}]},{"type":"text","value":", click on "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"Note"}]},{"type":"text","value":" to expand it, then select all permissions. Once you're done, click Save at the top right."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2022/03/Screen-Shot-2022-01-31-at-5.01.53-PM.png.jpeg","className":["kg-image"],"alt":"","loading":"lazy","width":880,"height":780},"children":[]}]},{"type":"element","tagName":"h2","properties":{"id":"setup-react-native"},"children":[{"type":"text","value":"Setup React Native"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Next, you'll set up a React Native project."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"First, you need to install the "},{"type":"element","tagName":"a","properties":{"href":"https://docs.expo.dev/workflow/expo-cli/"},"children":[{"type":"text","value":"Expo CLI"}]},{"type":"text","value":" if you don't have it installed:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" i -g expo-cli"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Next, run the following command to create a new React Native project:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"expo init notes-app"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Choose "},{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"Blank"}]},{"type":"text","value":" when asked about the type of project to create."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Once that is done, change to the newly created directory "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"notes-app"}]},{"type":"text","value":" and install dependencies with NPM:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","builtin","class-name"]},"children":[{"type":"text","value":"cd"}]},{"type":"text","value":" notes-app\n"},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" i"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Now, you'll need to install the dependencies you'll need for this tutorial. First, start by installing some dependencies with Expo's CLI:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"expo "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" react-native-screens react-native-safe-area-context"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"These dependencies are necessary to add "},{"type":"element","tagName":"a","properties":{"href":"https://reactnavigation.org"},"children":[{"type":"text","value":"React Navigation"}]},{"type":"text","value":", which is a library that adds navigation capabilities between screens in your app."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"em","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"https://blog.shahednasser.com/react-native-navigation-tutorial"},"children":[{"type":"text","value":"Suggested Read: React Native Navigation Tutorial."}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Next, install the necessary dependencies with NPM:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" i react-native-paper @react-navigation/native @react-navigation/native-stack react-native-pell-rich-editor react-native-webview"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Here's what each dependency is for:"}]},{"type":"element","tagName":"ol","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"react-native-paper"}]},{"type":"text","value":": "},{"type":"element","tagName":"a","properties":{"href":"https://callstack.github.io/react-native-paper/index.html"},"children":[{"type":"text","value":"React Native Paper"}]},{"type":"text","value":" library to easily add styled-components in your app."}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"@react-navigation/native @react-navigation/native-stack"}]},{"type":"text","value":": More libraries for React Navigation."}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"react-native-pell-rich-editor"}]},{"type":"text","value":": a "},{"type":"element","tagName":"a","properties":{"href":"https://github.com/wxik/react-native-rich-editor"},"children":[{"type":"text","value":"Rich Editor"}]},{"type":"text","value":" element for React Native."}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"react-native-webview"}]},{"type":"text","value":": required by "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"react-native-pell-rich-editor"}]},{"type":"text","value":"."}]}]},{"type":"element","tagName":"h2","properties":{"id":"create-home-screen"},"children":[{"type":"text","value":"Create Home Screen"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The home screen displays a list of notes with just the title and the date. It will also have a "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"+"}]},{"type":"text","value":" button at the top right to add notes."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Create the file "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"screens/HomeScreen.js"}]},{"type":"text","value":" with the following content:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" axios "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"axios\""}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" useEffect"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" useState "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"react\""}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" FlatList"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" View "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"react-native\""}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" Caption"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" List"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" Snackbar "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"react-native-paper\""}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"export"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"default"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"HomeScreen"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" navigation "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"text","value":"notes"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" setNotes"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"useState"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"text","value":"loading"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" setLoading"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"useState"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","boolean"]},"children":[{"type":"text","value":"true"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"text","value":"error"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" setError"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"useState"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"''"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n  "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"useEffect"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"loadNotes"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n\n    "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" subscribe "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" navigation"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"addListener"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'focus'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"loadNotes"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n    "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"text","value":" subscribe"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"loadNotes"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    axios"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"get"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'http://<IP>:1337/api/notes'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"then"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" data "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setNotes"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"data"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"data"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setLoading"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","boolean"]},"children":[{"type":"text","value":"false"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"catch"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"e"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n        console"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"error"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"e"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setError"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'An error occurred, please try again later.'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setLoading"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","boolean"]},"children":[{"type":"text","value":"false"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"View"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"!"}]},{"type":"text","value":"loading "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"&&"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"!"}]},{"type":"text","value":"notes"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"length "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"&&"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Caption style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"textAlign"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'center'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"marginTop"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"10"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"You have no notes"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Caption"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"FlatList\n        data"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"notes"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n        renderItem"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" item "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"List"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Item \n            key"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"item"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"id"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n            title"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"item"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"attributes"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"title"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n            description"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"item"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"attributes"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"date"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n            onPress"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" navigation"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"navigate"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'Editor'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n                "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"note"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" item\n            "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n            "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"      \n        refreshing"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"loading"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n        onRefresh"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"loadNotes"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n        style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"width"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'100%'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"height"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'100%'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Snackbar visible"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"error"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"length "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"0"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" onDismiss"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setError"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"''"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"error"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Snackbar"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"View"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You first create the state variable "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"notes"}]},{"type":"text","value":" which will hold the notes when received from the Strapi backend. You use a "},{"type":"element","tagName":"a","properties":{"href":"https://reactnative.dev/docs/flatlist"},"children":[{"type":"text","value":"FlatList"}]},{"type":"text","value":" component to display the notes. This will render each note using the "},{"type":"element","tagName":"a","properties":{"href":"https://callstack.github.io/react-native-paper/list-item.html"},"children":[{"type":"text","value":"List.Item"}]},{"type":"text","value":" component from React Native Paper. The title of the item will be the title of the note, and the description will be the date of the note."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"When the item in the list is clicked, the user will be taken to the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Editor"}]},{"type":"text","value":" screen (which you'll create in the next section)."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The fetching of the notes will happen in the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"loadNotes"}]},{"type":"text","value":" function. This function is called when the screen first opens, when the screen gains focus, and when the flat list is refreshed."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"loadNotes"}]},{"type":"text","value":" function, you send a request to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"http://<IP>:1337/api/notes"}]},{"type":"text","value":". Notice that to run the app on your phone, you need to use your machine's network IP. So, replace "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"<IP>"}]},{"type":"text","value":" with your machine's IP."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This endpoint is Strapi's Endpoint for "},{"type":"element","tagName":"a","properties":{"href":"https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest-api.html#get-entries"},"children":[{"type":"text","value":"fetching the entries"}]},{"type":"text","value":" of a content type. You then set the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"notes"}]},{"type":"text","value":" state variable to the data received from Strapi."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Next, you need to make changes to the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"App.js"}]},{"type":"text","value":" file to show different screens."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Open "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"App.js"}]},{"type":"text","value":" and replace the content with the following:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" NavigationContainer "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'@react-navigation/native'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" createNativeStackNavigator "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'@react-navigation/native-stack'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" IconButton "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native-paper'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" EditorScreen "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'./screens/EditorScreen'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" HomeScreen "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'./screens/HomeScreen'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" Stack "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"createNativeStackNavigator"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"export"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"default"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"App"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"NavigationContainer"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Stack"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Navigator"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Stack"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Screen name"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Home\""}]},{"type":"text","value":" component"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"HomeScreen"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" options"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"navigation"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","function-variable","function"]},"children":[{"type":"text","value":"headerRight"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n            "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"IconButton icon"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'plus'"}]},{"type":"text","value":" onPress"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" navigation"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"navigate"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'Editor'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Stack"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Navigator"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"NavigationContainer"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Notice that the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Home"}]},{"type":"text","value":" screen has a button at the top right that will take you to the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Editor"}]},{"type":"text","value":" screen."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Now, let's run the app. In your terminal, run the following:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" start"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This will allow you to open the app on iOS or Android. You'll need the "},{"type":"element","tagName":"a","properties":{"href":"https://expo.dev/client"},"children":[{"type":"text","value":"Expo Go"}]},{"type":"text","value":" app on your phone. Then, on Android, open the app and scan the QR code in the terminal or the developer tool page to open the app. Alternatively, on iOS, you need to scan the QR code in your Camera app which will let you open the app in Expo Go."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"When you open the app, you'll see an empty home screen."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2022/03/IMG_2484-2.PNG","className":["kg-image"],"alt":"","loading":"lazy","width":880,"height":1904},"children":[]}]},{"type":"element","tagName":"h2","properties":{"id":"create-editor-screen"},"children":[{"type":"text","value":"Create Editor Screen"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Now, you'll create the editor screen which will show the user the editor with either the content filled (if editing an existing note) or an empty rich text editor."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Create "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"screens/EditorScreen.js"}]},{"type":"text","value":" with the following content:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" useLayoutEffect"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" useRef"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" useState "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" RichEditor"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" RichToolbar"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"react-native-pell-rich-editor\""}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" Keyboard"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" KeyboardAvoidingView"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" ScrollView"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" View "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" Button"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" Colors"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" Snackbar"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" Subheading"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" TextInput "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native-paper'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" axios "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'axios'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"export"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"default"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"EditorScreen"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" route"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" navigation "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" editor "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"useRef"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"text","value":"title"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" setTitle"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"useState"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"route"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"params "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"&&"}]},{"type":"text","value":" route"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"params"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"note "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"?"}]},{"type":"text","value":" route"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"params"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"note"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"attributes"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"title "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"''"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"text","value":"content"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" setContent"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"useState"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"route"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"params "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"&&"}]},{"type":"text","value":" route"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"params"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"note "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"?"}]},{"type":"text","value":" route"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"params"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"note"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"attributes"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"content "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"''"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"text","value":"error"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" setError"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"useState"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"''"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"saveNote"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    editor"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"current"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"blurContentEditor"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","comment"]},"children":[{"type":"text","value":"//lose focus for editor and close keyboard"}]},{"type":"text","value":"\n    Keyboard"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"dismiss"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" trimmedTitle "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" title"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"trim"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n      trimmedContent "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" content"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"trim"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"if"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"!"}]},{"type":"text","value":"trimmedTitle"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"length "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"||"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"!"}]},{"type":"text","value":"trimmedContent"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"length"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setError"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'Please fill both title and content'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"axios"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"method"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" route"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"params "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"&&"}]},{"type":"text","value":" route"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"params"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"note "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"?"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'PUT'"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'POST'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"url"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'http://<IP>:1337/api/notes'"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"+"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"route"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"params "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"&&"}]},{"type":"text","value":" route"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"params"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"note "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"?"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'/'"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"+"}]},{"type":"text","value":" route"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"params"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"note"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"id "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"''"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"data"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"data"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n          title"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n          content"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"date"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" Date"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"now"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"then"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","comment"]},"children":[{"type":"text","value":"//redirect back to home screen"}]},{"type":"text","value":"\n      navigation"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"goBack"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"catch"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"e"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n      console"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"error"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"e"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setError"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'An error occurred, please try again later'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"deleteNote"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    axios"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"delete"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'http://<IP>:1337/api/notes/'"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"+"}]},{"type":"text","value":" route"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"params"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"note"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"id"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"then"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","comment"]},"children":[{"type":"text","value":"//redirect back to home screen"}]},{"type":"text","value":"\n      navigation"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"goBack"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"catch"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"e"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n        console"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"error"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"e"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setError"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'An error occurred, please try again later.'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n\n  "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"useLayoutEffect"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    navigation"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setOptions"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"headerTitle"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" content"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"length "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"==="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"0"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"?"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'New Note'"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'Edit Note'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"headerRight"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" route"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"params "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"&&"}]},{"type":"text","value":" route"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"params"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"note "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"?"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Button color"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"Colors"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"redA100"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" onPress"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"deleteNote"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"Delete"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Button"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"View style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"margin"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"10"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"flex"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"1"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"justifyContent"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'space-between'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"TextInput label"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Title\""}]},{"type":"text","value":" value"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"title"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" onChangeText"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"setTitle"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" mode"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"outlined\""}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Subheading"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"Content"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Subheading"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"RichToolbar\n        editor"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"editor"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"ScrollView keyboardDismissMode"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'onDrag'"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"KeyboardAvoidingView behavior"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"position\""}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\tstyle"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"flex"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"1"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" keyboardVerticalOffset"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"250"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"RichEditor \n            style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"flex"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"1"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n            ref"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"editor"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" \n            onChange"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"setContent"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" \n            initialContentHTML"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"content"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" \n            placeholder"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'Start typing...'"}]},{"type":"text","value":"\n            useContainer "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Button onPress"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"saveNote"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" mode"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"contained\""}]},{"type":"text","value":" style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"marginTop"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"20"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n            Save\n          "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Button"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"KeyboardAvoidingView"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"ScrollView"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Snackbar visible"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"error"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"length "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"0"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" onDismiss"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setError"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"''"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"error"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Snackbar"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"View"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In this code snippet, you create a "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"editor"}]},{"type":"text","value":" ref variable for the Rich text editor. This is necessary for the library you're using. You also create a "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"title"}]},{"type":"text","value":" and "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"content"}]},{"type":"text","value":" state variables. These will be used to store the input values and will have as initial values the note's title and content if it exists."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"On the screen, you show a rich text editor with a toolbar to add advanced text editing. You also add a Save button and a Delete button for existing notes."}]},{"type":"element","tagName":"h3","properties":{"id":"save-a-note"},"children":[{"type":"text","value":"Save a Note"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"When the Save button is clicked, you check if the note exists or is new. If the note already exists, then, a "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"PUT"}]},{"type":"text","value":" request is sent to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"http://<IP>:1337/api/notes/<note_id>"}]},{"type":"text","value":", where "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"<IP>"}]},{"type":"text","value":" is your machine's IP and "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"<note_id>"}]},{"type":"text","value":" is the current note's ID. This Strapi endpoint is used to "},{"type":"element","tagName":"a","properties":{"href":"https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest-api.html#update-an-entry"},"children":[{"type":"text","value":"update an entry"}]},{"type":"text","value":" in a collection."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Alternatively, if the note is new, a "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"POST"}]},{"type":"text","value":" request is sent to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"http://<IP>:1337/api/notes"}]},{"type":"text","value":", where "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"<IP>"}]},{"type":"text","value":" is your machine's IP. This Strapi endpoint is used to "},{"type":"element","tagName":"a","properties":{"href":"https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest-api.html#create-an-entry"},"children":[{"type":"text","value":"create an entry"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Both requests accept in the body of the request a "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"data"}]},{"type":"text","value":" parameter with the entry's data. You pass the title, content, and current date."}]},{"type":"element","tagName":"h3","properties":{"id":"delete-a-note"},"children":[{"type":"text","value":"Delete a Note"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"When the Delete Button is clicked, a "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"DELETE"}]},{"type":"text","value":" request is sent to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"http://<IP>:1337/api/notes/<note_id>"}]},{"type":"text","value":", where "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"<IP>"}]},{"type":"text","value":" is your machine's IP and "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"<note_id>"}]},{"type":"text","value":" is the ID of the note to delete. Remember, this is only available if the note exists."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"After the note is saved or deleted, you take the user back to the home screen."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Next, you need to add the new screen to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"App.js"}]},{"type":"text","value":". Add it after the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Home"}]},{"type":"text","value":" screen:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Stack"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Screen name"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Editor\""}]},{"type":"text","value":" component"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"EditorScreen"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"That's all, now run the app if it's not running. Try first clicking on the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"+"}]},{"type":"text","value":" button at the top right of the home screen. You'll see a rich text editor with a toolbar and a Save button."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2022/03/IMG_2485-2.PNG","className":["kg-image"],"alt":"","loading":"lazy","width":880,"height":1904},"children":[]}]},{"type":"element","tagName":"h3","properties":{"id":"add-a-note"},"children":[{"type":"text","value":"Add a Note"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Try entering any content in both title and content fields. Once you're done, click Save. You'll be taken back to the home screen where you can see the new item you added."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2022/03/IMG_2472-2.PNG","className":["kg-image"],"alt":"","loading":"lazy","width":880,"height":1904},"children":[]}]},{"type":"element","tagName":"h2","properties":{"id":"edit-a-note"},"children":[{"type":"text","value":"Edit a Note"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Now, click on a note and edit its content, then click Save. If you click on that note again, you'll see that the content has been edited successfully."}]},{"type":"element","tagName":"h2","properties":{"id":"delete-a-note-1"},"children":[{"type":"text","value":"Delete a Note"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If you click on a note from the home screen, you'll notice a delete button at the top right of the screen."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2022/03/IMG_2471-2.PNG","className":["kg-image"],"alt":"","loading":"lazy","width":880,"height":1904},"children":[]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Click on the delete button and you'll be taken back to the home screen where you can see your note does not exist anymore."}]},{"type":"element","tagName":"h2","properties":{"id":"conclusion"},"children":[{"type":"text","value":"Conclusion"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This simple note app showcases how you can connect a React Native app to Strapi. Strapi makes it simple to add CMS capabilities to apps using React Native. Using a CMS like Strapi to easily manage the notes on your app allows you to also manage the notes on different platforms like on the web."}]}],"data":{"quirksMode":false}},"tableOfContents":[{"id":"setup-strapi","heading":"Setup Strapi","items":[{"id":"create-content-types","heading":"Create Content-Types"},{"id":"change-permissions","heading":"Change Permissions"}]},{"id":"setup-react-native","heading":"Setup React Native"},{"id":"create-home-screen","heading":"Create Home Screen"},{"id":"create-editor-screen","heading":"Create Editor Screen","items":[{"id":"save-a-note","heading":"Save a Note"},{"id":"delete-a-note","heading":"Delete a Note"},{"id":"add-a-note","heading":"Add a Note"}]},{"id":"edit-a-note","heading":"Edit a Note"},{"id":"delete-a-note-1","heading":"Delete a Note"},{"id":"conclusion","heading":"Conclusion"}]},"featureImageSharp":{"base":"How-to-Create-a-Notes-App-with-Strapi-v4-and-React-Native-5.webp","publicURL":"/static/53fcf20de38e44c013aa2b39f34c0a28/How-to-Create-a-Notes-App-with-Strapi-v4-and-React-Native-5.webp","imageMeta":{"width":1000,"height":420},"childImageSharp":{"fluid":{"base64":"data:image/webp;base64,UklGRkwAAABXRUJQVlA4IEAAAABwAwCdASoUAAgAPtFUo0uoJKMhsAgBABoJaQAAXe9xyZhdNAAA/vOsacWtB4DZdTywIyPM0KjJjVgEYCYgAAAA","aspectRatio":2.364864864864865,"src":"/static/53fcf20de38e44c013aa2b39f34c0a28/89afa/How-to-Create-a-Notes-App-with-Strapi-v4-and-React-Native-5.webp","srcSet":"/static/53fcf20de38e44c013aa2b39f34c0a28/9fca7/How-to-Create-a-Notes-App-with-Strapi-v4-and-React-Native-5.webp 175w,\n/static/53fcf20de38e44c013aa2b39f34c0a28/37a4e/How-to-Create-a-Notes-App-with-Strapi-v4-and-React-Native-5.webp 350w,\n/static/53fcf20de38e44c013aa2b39f34c0a28/89afa/How-to-Create-a-Notes-App-with-Strapi-v4-and-React-Native-5.webp 700w,\n/static/53fcf20de38e44c013aa2b39f34c0a28/47f67/How-to-Create-a-Notes-App-with-Strapi-v4-and-React-Native-5.webp 1000w","srcWebp":"/static/53fcf20de38e44c013aa2b39f34c0a28/89afa/How-to-Create-a-Notes-App-with-Strapi-v4-and-React-Native-5.webp","srcSetWebp":"/static/53fcf20de38e44c013aa2b39f34c0a28/9fca7/How-to-Create-a-Notes-App-with-Strapi-v4-and-React-Native-5.webp 175w,\n/static/53fcf20de38e44c013aa2b39f34c0a28/37a4e/How-to-Create-a-Notes-App-with-Strapi-v4-and-React-Native-5.webp 350w,\n/static/53fcf20de38e44c013aa2b39f34c0a28/89afa/How-to-Create-a-Notes-App-with-Strapi-v4-and-React-Native-5.webp 700w,\n/static/53fcf20de38e44c013aa2b39f34c0a28/47f67/How-to-Create-a-Notes-App-with-Strapi-v4-and-React-Native-5.webp 1000w","sizes":"(max-width: 700px) 100vw, 700px"}}}}},{"node":{"id":"Ghost__Post__61b1cb7ad752820612f17bad","title":"React Native Navigation Tutorial","slug":"react-native-navigation-tutorial","featured":false,"feature_image":"https://backend.shahednasser.com/content/images/2021/12/nathan-da-silva-FO7kUmBYVi0-unsplash-2.jpg","excerpt":"In this tutorial, you'll learn how to use React Navigation in your React Native app.","custom_excerpt":"In this tutorial, you'll learn how to use React Navigation in your React Native app.","visibility":"public","created_at_pretty":"9 Dec 2021","published_at_pretty":"9 Dec 2021","updated_at_pretty":"20 Dec 2021","created_at":"2021-12-09T09:25:14.000+00:00","published_at":"2021-12-09T13:38:31.000+00:00","updated_at":"2021-12-20T08:50:59.000+00:00","meta_title":null,"meta_description":null,"og_description":null,"og_image":null,"og_title":null,"twitter_description":null,"twitter_image":null,"twitter_title":null,"authors":[{"slug":"shahed","url":"https://backend.shahednasser.com/author/shahed/","name":"Shahed Nasser","bio":null,"cover_image":null,"profile_image":"https://backend.shahednasser.com/content/images/2022/03/IMG_0591.jpg","location":null,"website":null,"twitter":null,"facebook":null,"meta_title":null,"meta_description":null,"coverImageSharp":null,"profileImageSharp":null}],"primary_author":{"slug":"shahed","url":"https://backend.shahednasser.com/author/shahed/","name":"Shahed Nasser","bio":null,"cover_image":null,"profile_image":"https://backend.shahednasser.com/content/images/2022/03/IMG_0591.jpg","location":null,"website":null,"twitter":null,"facebook":null,"meta_title":null,"meta_description":null,"coverImageSharp":null,"profileImageSharp":{"base":"IMG_0591.jpg","publicURL":"/static/ceb49c3c631485453e71e00d7f84b069/IMG_0591.jpg","imageMeta":{"width":1182,"height":1179},"childImageSharp":{"fluid":{"base64":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAUABQDASIAAhEBAxEB/8QAGAABAQEBAQAAAAAAAAAAAAAAAAMEAQL/xAAWAQEBAQAAAAAAAAAAAAAAAAADBAL/2gAMAwEAAhADEAAAAdXiFM6i0CohUWXoKn//xAAcEAACAgIDAAAAAAAAAAAAAAACAwESBBEhM0H/2gAIAQEAAQUCWySE3WEr7SzbXjAj4iKty+sOQ//EABYRAQEBAAAAAAAAAAAAAAAAAAERIP/aAAgBAwEBPwEhj//EABQRAQAAAAAAAAAAAAAAAAAAACD/2gAIAQIBAT8BH//EAB4QAAIBBAMBAAAAAAAAAAAAAAABIRESMUECECJx/9oACAEBAAY/ApVGWvOjzgtUwLlTZA0sdL4f/8QAHBAAAwACAwEAAAAAAAAAAAAAAAERITFBkbHB/9oACAEBAAE/IahkCy+N2GwZpjQiJHJCspUFY0QrSi+HqiW2rgf/2gAMAwEAAgADAAAAEPw3/wD/xAAYEQEBAAMAAAAAAAAAAAAAAAAAARExQf/aAAgBAwEBPxCtjDqP/8QAFxEBAQEBAAAAAAAAAAAAAAAAAQAxEf/aAAgBAgEBPxBFus6Tt//EAB8QAQEAAgIBBQAAAAAAAAAAAAERACExQWFRcYGR0f/aAAgBAQABPxAuaBPPzkO1wyX7F4wkwXanfZrFQgeqE9JgS14vVOvrERIJomVBKwt2jebAeP0yVa8h1n//2Q==","aspectRatio":1,"src":"/static/ceb49c3c631485453e71e00d7f84b069/31709/IMG_0591.jpg","srcSet":"/static/ceb49c3c631485453e71e00d7f84b069/f340b/IMG_0591.jpg 28w,\n/static/ceb49c3c631485453e71e00d7f84b069/22d64/IMG_0591.jpg 55w,\n/static/ceb49c3c631485453e71e00d7f84b069/31709/IMG_0591.jpg 110w,\n/static/ceb49c3c631485453e71e00d7f84b069/aa249/IMG_0591.jpg 165w,\n/static/ceb49c3c631485453e71e00d7f84b069/0dc33/IMG_0591.jpg 220w,\n/static/ceb49c3c631485453e71e00d7f84b069/d8257/IMG_0591.jpg 1182w","srcWebp":"/static/ceb49c3c631485453e71e00d7f84b069/8678c/IMG_0591.webp","srcSetWebp":"/static/ceb49c3c631485453e71e00d7f84b069/59cda/IMG_0591.webp 28w,\n/static/ceb49c3c631485453e71e00d7f84b069/7da75/IMG_0591.webp 55w,\n/static/ceb49c3c631485453e71e00d7f84b069/8678c/IMG_0591.webp 110w,\n/static/ceb49c3c631485453e71e00d7f84b069/f282e/IMG_0591.webp 165w,\n/static/ceb49c3c631485453e71e00d7f84b069/a7b21/IMG_0591.webp 220w,\n/static/ceb49c3c631485453e71e00d7f84b069/63099/IMG_0591.webp 1182w","sizes":"(max-width: 110px) 100vw, 110px"}}}},"primary_tag":{"slug":"react-native","url":"https://backend.shahednasser.com/tag/react-native/","name":"React Native","visibility":"public","feature_image":null,"description":null,"meta_title":null,"meta_description":null,"featureImageSharp":null},"tags":[{"slug":"react-native","url":"https://backend.shahednasser.com/tag/react-native/","name":"React Native","visibility":"public","feature_image":null,"description":null,"meta_title":null,"meta_description":null,"featureImageSharp":null},{"slug":"js","url":"https://backend.shahednasser.com/tag/js/","name":"Javascript","visibility":"public","feature_image":"https://backend.shahednasser.com/content/images/2022/01/photo-1592609931095-54a2168ae893-2.jpeg","description":"Learn more about Javascript through tutorials, articles, and tips.","meta_title":null,"meta_description":"Learn more about Javascript through tutorials, articles and tips.","featureImageSharp":null},{"slug":"beginner","url":"https://backend.shahednasser.com/tag/beginner/","name":"Beginners","visibility":"public","feature_image":"https://backend.shahednasser.com/content/images/2022/01/photo-1521185496955-15097b20c5fe-2.jpeg","description":"Tutorials, articles, and tips to help beginners accelerate their journey in programming.","meta_title":"Beginners","meta_description":"Tutorials, articles, and tips to help beginners accelerate their journey in programming.","featureImageSharp":null}],"plaintext":"React Native [https://reactnative.dev] is one of the most popular cross-platform\napp development frameworks. Using JavaScript, you can develop native apps for\nboth Android and iOS.\n\nOne important part of creating apps is being able to navigate between screens.\nIn this tutorial, you'll learn how to use React Navigation\n[https://reactnavigation.org] in your app to add navigation. This will include\nbasic navigation from one screen to another, going back to the previous screen,\npassing parameters, listening to events, and more.\n\nThis tutorial will not explain the basics of creating a React Native app. If\nyou're interested in learning about that, you can check out my other tutorial \nReact Native Tutorial: Create Your First App\n[https://blog.shahednasser.com/react-native-tutorial-create-your-first-app].\n\nYou can find the code for this tutorial on this GitHub repository\n[https://github.com/shahednasser/react-navigation-tutorial].\n\nPrerequisites \nMake sure you have both Node.js [https://nodejs.org/en/] and NPM installed on\nyour machine. You can check if they're installed with the following command:\n\nnode -v\nnpm -v\n\nIf they're not installed, you can install Node.js [https://nodejs.org/en/] and\nNPM will be installed automatically with it.\n\n After that, make sure you install Expo [https://expo.dev]'s CLI if you don't\nhave it installed:\n\nnpm install -g expo-cli\n\nIf you're not familiar with what Expo is, Expo provides a set of tools built\naround React. Most importantly, it allows you to write and build your React\nNative app in minutes.\n\nYou should also install Expo Go [https://expo.dev/client] on your device to be\nable to test the app as we go through the tutorial.\n\nProject Setup\nStart by creating a new React Native project using Expo's CLI:\n\nexpo init react-navigation-tutorial —npm\n\nYou'll be then prompted to choose the type of app, choose \"blank\".\n\nAfter that the init command will install the dependencies you need for your\nReact Native project.\n\nOnce it's done, change to the directory of the project:\n\ncd react-navigation-tutorial\n\nNow, you'll install the dependencies required to use React Navigation. First,\ninstall the building blocks libraries using Expo's CLI with the following\ncommand:\n\nexpo install react-native-screens react-native-safe-area-context\n\nSecond, install the native stack navigator library:\n\nnpm install @react-navigation/native-stack\n\nNow, you have all the libraries required to start using React Navigation.\n\nFinally, install React Native Paper\n[https://callstack.github.io/react-native-paper/index.html] to have\nbeautifully-styled components in your app:\n\nnpm install react-native-paper\n\nSet Up React Navigation\nBefore you can start adding routes to your app, you need to create a Stack\nNavigator. This stack navigator will be used to create screens and navigate\nbetween them.\n\nIn App.js, change the content to the following:\n\nimport React from 'react';\nimport { NavigationContainer } from '@react-navigation/native';\nimport { createNativeStackNavigator } from '@react-navigation/native-stack';\nimport { Provider as PaperProvider } from 'react-native-paper';\nimport HomeScreen from './screens/HomeScreen';\n\nconst Stack = createNativeStackNavigator()\n\nexport default function App() {\n  return (\n    <PaperProvider>\n      <NavigationContainer>\n        <Stack.Navigator>\n          <Stack.Screen name=\"Home\" component={HomeScreen} />\n        </Stack.Navigator>\n    </NavigationContainer>\n    </PaperProvider>\n  );\n}\n\n\nNotice that in the returned value of App, you first have <PaperProvider> at the\ntop of the elements. This is just used to make sure all screens share the same\ntheme.\n\nNext, you have the <NavigationContainer>. This component manages the navigation\ntree and contains the navigation state. So, it should wrap Stack navigators.\n\nInside <NavigationContainer> you have <Stack.Navigator>. Stack is created using \ncreateNativeStackNavigator. This function returns an object containing 2\nproperties: Screen and Navigator. The Navigator property is a React element and\nit should be used to wrap the Screen elements to manage routing configurations.\n\nSo, inside <Stack.Navigator> you'll have one or more <Stack.Screen> components.\nFor each route, you'll have a <Stack.Screen> component. Now, you just have one\ncomponent that points to the Home route.\n\nNotice that a Screen component takes the name prop, which is the name of the\nroute and will be referenced later on when navigating to this route, and the \ncomponent property which is the component to render for this route.\n\nAs you can see, you're passing HomeScreen component to the Home route, so you\nneed to create it now.\n\nCreate the directory screens, and inside that directory create a new file \nHomeScreen.js with the following content:\n\nimport React from 'react';\nimport { ScrollView, StyleSheet } from 'react-native';\nimport { Button, Card } from 'react-native-paper';\nimport { DefaultTheme } from 'react-native-paper';\n\nfunction HomeScreen () {\n  return (\n    <ScrollView style={styles.scrollView}>\n      <Card style={styles.card}>\n        <Card.Title title=\"Home Screen\" />\n      </Card>\n    </ScrollView>\n  )\n}\n\nconst styles = StyleSheet.create({\n  scrollView: {\n    backgroundColor: DefaultTheme.colors.background,\n    paddingTop: 10\n  },\n  card: {\n    width: '90%',\n    marginLeft: 'auto',\n    marginRight: 'auto'\n  }\n});\n\nexport default HomeScreen\n\nThis will create a basic home screen with a ScrollView\n[https://reactnative.dev/docs/scrollview] component containing a Card\n[https://callstack.github.io/react-native-paper/card.html] component with the\ntitle \"Home Screen\".\n\nYou just created your first route with React Navigation! Let's test it out.\n\nIn your terminal run to start your app:\n\nnpm start\n\nThen, you'll be able to run the app on Expo Go on your phone by scanning the QR\ncode on the Expo Go app on Android or on the Camera app on iOS.\n\nOnce the app run, you'll see the Home screen that you created as it's the\ndefault and only route.\n\nNavigate to Another Screen\nIn this section, you'll learn how to navigate from one screen to another.\n\nScreens that are inside the Stack Navigation, like HomeScreen in this app,\nreceive a navigation prop. This prop allows us to navigate to other screens in\nthe app.\n\nLet's first create the screen you'll navigate to. Create the file \nscreens/BookScreen.js with the following content:\n\nimport React from 'react';\nimport { StyleSheet, View } from 'react-native';\nimport { Card } from 'react-native-paper';\nimport { DefaultTheme } from 'react-native-paper';\n\nfunction BookScreen () {\n  return (\n    <View style={styles.container}>\n      <Card style={styles.card}>\n        <Card.Title title=\"This is Books Screen\" />\n      </Card>\n    </View>\n  );\n}\n\nconst styles = StyleSheet.create({\n  container: {\n    flex: 1,\n    flexDirection: 'column',\n    backgroundColor: DefaultTheme.colors.background,\n    alignItems: 'center',\n    paddingTop: 10\n  },\n  card: {\n    width: '90%'\n  }\n});\n\nexport default BookScreen;\n\nThis screen is similar to HomeScreen. It just shows a card with the title \"This\nis Books Screen\".\n\nNext, add the new route in App.js for BookScreen below the \"Home\" route:\n\n<Stack.Screen name=\"Book\" component={BookScreen} />\n\nDon't forget to import BookScreen below the imports at the beginning of App.js:\n\nimport BookScreen from './screens/BookScreen';\n\nNow, you can navigate to the \"Book\" route inside this stack navigation. To see\nhow it works, you'll add a button in HomeScreen that when the user clicks will\nnavigate to BookScreen.\n\nIn HomeScreen, add the navigation prop to the function:\n\nfunction HomeScreen ({ navigation })\n\nThen, change the returned value of the function to the following:\n\nreturn (\n    <ScrollView style={styles.scrollView}>\n      <Card style={styles.card}>\n        <Card.Title title=\"Navigate to 'Book' Screen\" />\n        <Card.Content>\n          <Button mode=\"contained\" onPress={() => navigation.navigate('Book')}>\n            Navigate\n          </Button>\n        </Card.Content>\n      </Card>\n    </ScrollView>\n  )\n\nYou change the title of the card to \"Navigate to 'Book' Screen\". Then, inside\nthe content of the card, you add a Button\n[https://callstack.github.io/react-native-paper/button.html] component with \nonPress listener. This listener will be executed when the user presses on the\nbutton.\n\nInside the listener, you use the navigation prop to navigate to the Book screen\nusing the method navigate. The method navigate takes the name of the route to\nnavigate to.\n\nLet's test it out. Run the app again if it isn't running. You should see a new\nbutton on the Home screen.\n\nTry clicking on the Navigate button. You'll be navigated to the BookScreen.\n\nNotice how the back button in the navigation bar is added automatically when you\nnavigate to another screen. You can use it to go back to the previous screen,\nwhich is in this case the Home screen.\n\nNavigate with Parameters\nIn a lot of cases, you'll need to navigate to another screen and pass it\nparameters. In this section, you'll create an input that allows the user to\nenter their name, then when they submit you'll open a new screen called \nNameScreen which will show a greeting to the user with the name they entered.\n\nStart by adding a new state variable to hold the value of the input you'll add\nsoon in HomeScreen.js:\n\nconst [name, setName] = useState('');\n\nMake sure to add an import for useState at the beginning of the file:\n\nimport React, { useState } from 'react';\n\nThen, add a new Card component below the existing one:\n\n<Card style={styles.card}>\n    <Card.Title title=\"Navigate with Parameters\" />\n    <Card.Content>\n        <TextInput mode=\"outlined\" label=\"Name\" value={name} onChangeText={(text) => setName(text)} style={styles.textInput} />\n            <Button mode=\"contained\" disabled={name.length === 0} onPress={() => navigation.navigate('Name', { name })}>\n                Navigate\n    \t</Button>\n    </Card.Content>\n</Card>\n\nThis new card has a TextInput\n[https://callstack.github.io/react-native-paper/text-input.html] with the value \nname, and on the onChangeText event, which occurs when the user makes changes to\nthe text inside the input, you change the value of the name state variable.\n\nBelow the input, you have a button that is disabled when the name state variable\nis empty. You also add an onPress event listener which navigates the user to the \nName route. \n\nNotice that you're using the same navigation.navigate method that you used\nbefore to navigate to the \"Book\" route, however, this time you pass a second\nparameter to the method. This method accepts as a second parameter an object of\nparameters you want to pass. Here, you pass the name variable inside the object.\n\nOne last thing you need to do in the HomeScreen is change the styles object to\nthe following:\n\nconst styles = StyleSheet.create({\n  scrollView: {\n    backgroundColor: DefaultTheme.colors.background,\n    paddingTop: 10\n  },\n  card: {\n    width: '90%',\n    marginLeft: 'auto',\n    marginRight: 'auto',\n    marginBottom: 10\n  },\n  textInput: {\n    marginBottom: 10\n  }\n});\n\nThis just makes some changes to the card property and adds a new property \ntextInput.\n\nYou'll now create the NameScreen which will be the component for the \"Name\"\nroute you'll add soon. Create screens/NameScreen.js with the following content:\n\nimport React from 'react';\nimport { StyleSheet, View } from 'react-native';\nimport { Card } from 'react-native-paper';\nimport { DefaultTheme } from 'react-native-paper';\n\nfunction NameScreen ({ route }) {\n  const { name } = route.params;\n\n  return (\n    <View style={styles.container}>\n      <Card style={styles.card}>\n        <Card.Title title={`Hello, ${name}`} />\n      </Card>\n    </View>\n  );\n}\n\nconst styles = StyleSheet.create({\n  container: {\n    flex: 1,\n    flexDirection: 'column',\n    backgroundColor: DefaultTheme.colors.background,\n    alignItems: 'center',\n    paddingTop: 10\n  },\n  card: {\n    width: '90%'\n  }\n});\n\nexport default NameScreen;\n\nThis screen is essentially the same as BookScreen, however, notice the route \nprop passed to the function.\n\nAs mentioned before, the components inside the navigation stack receive a \nnavigation prop to navigate between screens. They also receive a route prop\nwhich you can use to get the parameters passed to the screen using route.params.\n\nSo, in NameScreen, you retrieve the value entered in the Name input in the \nHomeScreen, which is passed when navigating to the NameScreen when the button is\nclicked using route.params:\n\nconst { name } = route.params;\n\nYou then show the user a greeting inside a card using the name parameter.\n\nOne last thing left to do is add the \"Name\" route to the navigation stack. Add a\nnew <Stack.Screen> below the previous ones in App.js:\n\n<Stack.Screen name=\"Name\" component={NameScreen} />\n\nAnd import NameScreen below other imports at the beginning of the file:\n\nimport NameScreen from './screens/NameScreen';\n\nLet's test it out. Run the app if it isn't already running. You'll see that\nthere's a new card on the Home screen with an input and a button.\n\nTry entering your name, then click the \"Navigate\" button below the input. You'll\nbe navigated to the NameScreen and you'll see your name.\n\nYou can try going back then changing the value of the name. The name in the \nNameScreen will change accordingly.\n\nConfigure the Header\nChange the title\nSometimes, you want the title of a route to be different than the name of the\nroute, or you want the title to be dynamic based on a parameter passed or some\nother logic.\n\nIn this section, you'll add a new input in HomeScreen that will let you to enter\na title, then on clicking the navigate button you'll be navigated to a new\nscreen TitleScreen, whose title will change based on the title entered in the\ninput in HomeScreen.\n\nStart by adding a new state variable in HomeScreen.js to store the title:\n\nconst [title, setTitle] = useState('');\n\nThen, add a new card below the previous cards:\n\n<Card style={styles.card}>\n        <Card.Title title=\"Navigate to Route with Title\" />\n        <Card.Content>\n          <TextInput mode=\"outlined\" label=\"Title\" value={title} onChangeText={(text) => setTitle(text)} style={styles.textInput} />\n          <Button mode=\"contained\" disabled={title.length === 0} onPress={() => navigation.navigate('Title', { title })}>\n            Navigate\n          </Button>\n        </Card.Content>\n      </Card>\n\nThis is pretty much the same as the card we added in the previous section. The\nonly difference is that it uses the title state variable, and the listener for \nonPress for the button navigates to the route \"Title\", passing the title as a\nparameter.\n\nNext, create the file screens/Title.js with the following content:\n\nimport React from 'react';\nimport { StyleSheet, View } from 'react-native';\nimport { Card } from 'react-native-paper';\nimport { DefaultTheme } from 'react-native-paper';\n\nfunction TitleScreen () {\n  return (\n    <View style={styles.container}>\n      <Card style={styles.card}>\n        <Card.Title title=\"This is title screen\" />\n      </Card>\n    </View>\n  );\n}\n\nconst styles = StyleSheet.create({\n  container: {\n    flex: 1,\n    flexDirection: 'column',\n    backgroundColor: DefaultTheme.colors.background,\n    alignItems: 'center',\n    paddingTop: 10\n  },\n  card: {\n    width: '90%'\n  }\n});\n\nexport default TitleScreen;\n\nThis screen has nothing special. It just shows a card with the title \"This is\ntitle screen\". It doesn't even use the title parameter.\n\nThat's because you can change the title of a screen by passing an options \nparameter to <Stack.Screen> when adding the route.\n\nIn App.js, add an import for TitleScreen below other imports at the beginning of\nthe file:\n\nimport TitleScreen from './screens/TitleScreen';\n\nThen, add the new route below previous <Stack.Screen>:\n\n<Stack.Screen name=\"Title\" component={TitleScreen} options={({route}) => ({title: route.params.title})} />\n\nEvery Stack.Screen component can take an options prop. The options prop can be\nan object like so:\n\noptions={{title: \"Hello\"}}\n\nThis is enough if your options are static. However, if the value for any of the\noptions is dynamic, like in this example, you can instead pass it a function\nthat returns an object. This function can receive as a parameter route, which is\nsimilar to the route parameter you used in NameScreen:\n\noptions={({route}) => ({title: route.params.title})}\n\nIn this function, you return an object that has a title property with the value \nroute.params.title. So, when the user enters a title in the input and clicks on\nthe Navigate button, the title will be passed to the route, which will change\nthe title of \"Title\" route using the function passed to the options prop.\n\nLet's test it out. Run the app if it's not running already. You should see a new\ncard on the Home screen with a new input:\n\nTry entering any title you want in the input then click on Navigate. You'll see\nthat you'll be navigated to the TitleScreen, but the title will be the value you\nentered in the input.\n\nYou can try going back then changing the value entered in the input. The title\nof the screen will change accordingly.\n\nAdd Header Button\nAnother option you can add is header buttons. You can customize what your header\nshows on the left and right by using the headerRight and headerLeft properties\nin the options param of <Stack.Screen>.\n\nIn this section, you'll add a button to the right of the header of the Home\nscreen which will show a user an alert when they click on it.\n\nIn App.js, add to the \"Home\" route a prop option:\n\n<Stack.Screen name=\"Home\" component={HomeScreen} options={{\n            headerRight: () => (\n              <IconButton icon=\"alert-outline\" onPress={() => alert('You\\'re awesome!')} color={DefaultTheme.colors.notification} />\n            )\n}} />\n\nIn the options prop, you pass an object with the property headerRight. The \nheaderRight property can be a component that you can render elements inside. You\nrender an IconButton\n[https://callstack.github.io/react-native-paper/icon-button.html] component,\nwhich is a button that only has an icon without text. In the onPress event\nlistener, you show an alert to the user.\n\nThat's all. Run the app if it isn't running already. You'll see a new icon at\nthe top right of the header in Home Screen.\n\nClick on it and you'll see an alert.\n\nNavigation Events\nIn React Navigation, you can subscribe to two events: focus and blur. The focus \nevent will occur every time the screen is opened and is currently the main\nscreen. The blur event will occur whenever a screen was in focus but navigation\noccurs that makes the screen not the current main screen. Simply put, the focus \nevent is when the screen is visible to the user, and the blur event occurs when\na screen was visible to a user but isn't anymore. \n\nIn this section, you'll add a counter that will count how many times you\nnavigated to other screens from the home screen. So, this counter will increment\nin the blur event.\n\nTo subscribe to events, in a useEffect callback inside a component, you can use \nnavigation.addListener passing it the name of the event as a first parameter,\nand the event handler as a second parameter. The addListener method returns an\nunsubscribe function which you should return in the useEffect callback.\n\nIn HomeScreen.js, add an import for useEffect at the beginning of the file:\n\nimport React, { useEffect, useState } from 'react';\n\nThen, add a new state variable counter inside the HomeScreen component:\n\nconst [counter, setCounter] = useState(0);\n\nAfter that add the useEffect callback that will register the event handle for\nthe blur event:\n\nuseEffect(() => {\n    return navigation.addListener('blur', () => {\n      setCounter(counter + 1);\n    });\n  });\n\nAs you can see, you use navigation.addListener to add an event listener to the \nblur event. The function passed as a second parameter is the handler of the\nevent. It will be executed whenever the screen is out of focus (not the screen\nvisible to the user). Inside the event handler, you increment the counter by 1.\n\nFinally, you'll show the counter at the top of the screen. In ScrollView, add a\nnew card before the previously added cards:\n\n<Card style={styles.card}>\n\t<Card.Title title={`Navigation Count: ${counter}`} />\n</Card>\n\nLet's test it out. Run the app if it's not already running. You should see a\ncard with a count of navigation at the top of the screen.\n\nGo Back\nThe last thing you'll learn in this tutorial is how to go back to the previous\nscreen. As you've seen throughout the tutorial, when you navigate to a screen\nyou'll see a back button in the header which you can use to go back to the\nprevious screen.\n\nAlthough this is sufficient in most cases, sometimes you want to go back to the\nprevious screen programmatically. You'll create in this section a new screen \nBackScreen which you can go to from the HomeScreen. This screen will have a back\nbutton in its content and when you click on it you can go back to the previous\nscreen, which is the HomeScreen.\n\nCreate the file screens/BackScreen.js with the following content:\n\nimport React from 'react';\nimport { StyleSheet, View } from 'react-native';\nimport { Button, Card } from 'react-native-paper';\nimport { DefaultTheme } from 'react-native-paper';\n\nfunction BackScreen ({ navigation }) {\n  return (\n    <View style={styles.container}>\n      <Card style={styles.card}>\n        <Card.Title title=\"This is Back Screen\" />\n        <Card.Content>\n          <Button mode=\"contained\" onPress={() => navigation.goBack()}>\n            Go Back\n          </Button>\n        </Card.Content>\n      </Card>\n    </View>\n  );\n}\n\nconst styles = StyleSheet.create({\n  container: {\n    flex: 1,\n    flexDirection: 'column',\n    backgroundColor: DefaultTheme.colors.background,\n    alignItems: 'center',\n    paddingTop: 10\n  },\n  card: {\n    width: '90%'\n  }\n});\n\nexport default BackScreen;\n\nThis screen is pretty much the same as other screens. The things you should note\nis that, first, the screen has uses the navigation prop that is passed to\ncomponents inside the navigation stack. Second, the screen has a button inside a\ncard which, on press, will use the navigation prop to go back using the goBack \nmethod:\n\n<Button mode=\"contained\" onPress={() => navigation.goBack()}>\n\nNow, go to the HomeScreen and add a new card at the end of the ScrollView:\n\n<Card style={styles.card}>\n    <Card.Title title=\"Navigate to 'Back' Screen\" />\n    <Card.Content>\n        <Button mode=\"contained\" onPress={() => navigation.navigate('Back')}>\n            Navigate\n    \t</Button>\n    </Card.Content>\n</Card>\n\nThis card just shows a button to navigate to the route \"Back\". Let's add that\nroute now.\n\nIn App.js add a new <Stack.Screen> component below the previously added ones:\n\n<Stack.Screen name=\"Back\" component={BackScreen} />\n\nIt's ready now. Run the app if it isn't already running. You'll see a new card\nat the end of the list.\n\nClick on \"Navigate\" on the last card. You'll be navigated to the BackScreen.\n\nClick on the \"Go Back\" button in the card. You'll be taken back to the \nHomeScreen.\n\nConclusion\nIn this tutorial, you learned how to use React Navigation to navigate between\nscreens, pass a parameter from one screen to another, configure the header of a\nscreen, add navigation event listeners, and go back programmatically to the\nprevious screen.\n\nAlthough this covers most use cases for using React Navigation, be sure to check\nout their documentation [https://reactnavigation.org/docs/getting-started] for\nmore details on how to use it.","html":"<p><a href=\"https://reactnative.dev\">React Native</a> is one of the most popular cross-platform app development frameworks. Using JavaScript, you can develop native apps for both Android and iOS.</p><p>One important part of creating apps is being able to navigate between screens. In this tutorial, you'll learn how to use <a href=\"https://reactnavigation.org\">React Navigation</a> in your app to add navigation. This will include basic navigation from one screen to another, going back to the previous screen, passing parameters, listening to events, and more.</p><p>This tutorial will not explain the basics of creating a React Native app. If you're interested in learning about that, you can check out my other tutorial <a href=\"https://blog.shahednasser.com/react-native-tutorial-create-your-first-app\">React Native Tutorial: Create Your First App</a>.</p><p>You can find the code for this tutorial on <a href=\"https://github.com/shahednasser/react-navigation-tutorial\">this GitHub repository</a>.</p><h2 id=\"prerequisites\">Prerequisites </h2><p>Make sure you have both <a href=\"https://nodejs.org/en/\">Node.js</a> and NPM installed on your machine. You can check if they're installed with the following command:</p><pre><code class=\"language-bash\">node -v\nnpm -v</code></pre><p>If they're not installed, you can <a href=\"https://nodejs.org/en/\">install Node.js</a> and NPM will be installed automatically with it.</p><p> After that, make sure you install <a href=\"https://expo.dev\">Expo</a>'s CLI if you don't have it installed:</p><pre><code class=\"language-bash\">npm install -g expo-cli</code></pre><p>If you're not familiar with what Expo is, Expo provides a set of tools built around React. Most importantly, it allows you to write and build your React Native app in minutes.</p><p>You should also install <a href=\"https://expo.dev/client\">Expo Go</a> on your device to be able to test the app as we go through the tutorial.</p><h2 id=\"project-setup\">Project Setup</h2><p>Start by creating a new React Native project using Expo's CLI:</p><pre><code class=\"language-bash\">expo init react-navigation-tutorial —npm</code></pre><p>You'll be then prompted to choose the type of app, choose \"blank\".</p><p>After that the <code>init</code> command will install the dependencies you need for your React Native project.</p><p>Once it's done, change to the directory of the project:</p><pre><code class=\"language-bash\">cd react-navigation-tutorial</code></pre><p>Now, you'll install the dependencies required to use React Navigation. First, install the building blocks libraries using Expo's CLI with the following command:</p><pre><code class=\"language-bash\">expo install react-native-screens react-native-safe-area-context</code></pre><p>Second, install the native stack navigator library:</p><pre><code class=\"language-bash\">npm install @react-navigation/native-stack</code></pre><p>Now, you have all the libraries required to start using React Navigation.</p><p>Finally, install <a href=\"https://callstack.github.io/react-native-paper/index.html\">React Native Paper</a> to have beautifully-styled components in your app:</p><pre><code class=\"language-bash\">npm install react-native-paper</code></pre><h2 id=\"set-up-react-navigation\">Set Up React Navigation</h2><p>Before you can start adding routes to your app, you need to create a Stack Navigator. This stack navigator will be used to create screens and navigate between them.</p><p>In <code>App.js</code>, change the content to the following:</p><pre><code class=\"language-js\">import React from 'react';\nimport { NavigationContainer } from '@react-navigation/native';\nimport { createNativeStackNavigator } from '@react-navigation/native-stack';\nimport { Provider as PaperProvider } from 'react-native-paper';\nimport HomeScreen from './screens/HomeScreen';\n\nconst Stack = createNativeStackNavigator()\n\nexport default function App() {\n  return (\n    &lt;PaperProvider&gt;\n      &lt;NavigationContainer&gt;\n        &lt;Stack.Navigator&gt;\n          &lt;Stack.Screen name=\"Home\" component={HomeScreen} /&gt;\n        &lt;/Stack.Navigator&gt;\n    &lt;/NavigationContainer&gt;\n    &lt;/PaperProvider&gt;\n  );\n}\n</code></pre><p>Notice that in the returned value of <code>App</code>, you first have <code>&lt;PaperProvider&gt;</code> at the top of the elements. This is just used to make sure all screens share the same theme.</p><p>Next, you have the <code>&lt;NavigationContainer&gt;</code>. This component manages the navigation tree and contains the navigation state. So, it should wrap Stack navigators.</p><p>Inside <code>&lt;NavigationContainer&gt;</code> you have <code>&lt;Stack.Navigator&gt;</code>. <code>Stack</code> is created using <code>createNativeStackNavigator</code>. This function returns an object containing 2 properties: <code>Screen</code> and <code>Navigator</code>. The <code>Navigator</code> property is a React element and it should be used to wrap the <code>Screen</code> elements to manage routing configurations.</p><p>So, inside <code>&lt;Stack.Navigator&gt;</code> you'll have one or more <code>&lt;Stack.Screen&gt;</code> components. For each route, you'll have a <code>&lt;Stack.Screen&gt;</code> component. Now, you just have one component that points to the <code>Home</code> route.</p><p>Notice that a <code>Screen</code> component takes the <code>name</code> prop, which is the name of the route and will be referenced later on when navigating to this route, and the <code>component</code> property which is the component to render for this route.</p><p>As you can see, you're passing <code>HomeScreen</code> component to the <code>Home</code> route, so you need to create it now.</p><p>Create the directory <code>screens</code>, and inside that directory create a new file <code>HomeScreen.js</code> with the following content:</p><pre><code class=\"language-js\">import React from 'react';\nimport { ScrollView, StyleSheet } from 'react-native';\nimport { Button, Card } from 'react-native-paper';\nimport { DefaultTheme } from 'react-native-paper';\n\nfunction HomeScreen () {\n  return (\n    &lt;ScrollView style={styles.scrollView}&gt;\n      &lt;Card style={styles.card}&gt;\n        &lt;Card.Title title=\"Home Screen\" /&gt;\n      &lt;/Card&gt;\n    &lt;/ScrollView&gt;\n  )\n}\n\nconst styles = StyleSheet.create({\n  scrollView: {\n    backgroundColor: DefaultTheme.colors.background,\n    paddingTop: 10\n  },\n  card: {\n    width: '90%',\n    marginLeft: 'auto',\n    marginRight: 'auto'\n  }\n});\n\nexport default HomeScreen</code></pre><p>This will create a basic home screen with a <a href=\"https://reactnative.dev/docs/scrollview\">ScrollView</a> component containing a <a href=\"https://callstack.github.io/react-native-paper/card.html\">Card</a> component with the title \"Home Screen\".</p><p>You just created your first route with React Navigation! Let's test it out.</p><p>In your terminal run to start your app:</p><pre><code class=\"language-bash\">npm start</code></pre><p>Then, you'll be able to run the app on Expo Go on your phone by scanning the QR code on the Expo Go app on Android or on the Camera app on iOS.</p><p>Once the app run, you'll see the Home screen that you created as it's the default and only route.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/12/IMG_1545.PNG\" class=\"kg-image\" alt loading=\"lazy\" width=\"1170\" height=\"2532\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1545.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1545.PNG 1000w, https://backend.shahednasser.com/content/images/2021/12/IMG_1545.PNG 1170w\" sizes=\"(min-width: 720px) 720px\"></figure><h2 id=\"navigate-to-another-screen\">Navigate to Another Screen</h2><p>In this section, you'll learn how to navigate from one screen to another.</p><p>Screens that are inside the Stack Navigation, like HomeScreen in this app, receive a <code>navigation</code> prop. This prop allows us to navigate to other screens in the app.</p><p>Let's first create the screen you'll navigate to. Create the file <code>screens/BookScreen.js</code> with the following content:</p><pre><code class=\"language-js\">import React from 'react';\nimport { StyleSheet, View } from 'react-native';\nimport { Card } from 'react-native-paper';\nimport { DefaultTheme } from 'react-native-paper';\n\nfunction BookScreen () {\n  return (\n    &lt;View style={styles.container}&gt;\n      &lt;Card style={styles.card}&gt;\n        &lt;Card.Title title=\"This is Books Screen\" /&gt;\n      &lt;/Card&gt;\n    &lt;/View&gt;\n  );\n}\n\nconst styles = StyleSheet.create({\n  container: {\n    flex: 1,\n    flexDirection: 'column',\n    backgroundColor: DefaultTheme.colors.background,\n    alignItems: 'center',\n    paddingTop: 10\n  },\n  card: {\n    width: '90%'\n  }\n});\n\nexport default BookScreen;</code></pre><p>This screen is similar to <code>HomeScreen</code>. It just shows a card with the title \"This is Books Screen\".</p><p>Next, add the new route in <code>App.js</code> for <code>BookScreen</code> below the \"Home\" route:</p><pre><code class=\"language-js\">&lt;Stack.Screen name=\"Book\" component={BookScreen} /&gt;</code></pre><p>Don't forget to import <code>BookScreen</code> below the imports at the beginning of <code>App.js</code>:</p><pre><code class=\"language-js\">import BookScreen from './screens/BookScreen';</code></pre><p>Now, you can navigate to the \"Book\" route inside this stack navigation. To see how it works, you'll add a button in <code>HomeScreen</code> that when the user clicks will navigate to <code>BookScreen</code>.</p><p>In <code>HomeScreen</code>, add the <code>navigation</code> prop to the function:</p><pre><code class=\"language-js\">function HomeScreen ({ navigation })</code></pre><p>Then, change the returned value of the function to the following:</p><pre><code class=\"language-js\">return (\n    &lt;ScrollView style={styles.scrollView}&gt;\n      &lt;Card style={styles.card}&gt;\n        &lt;Card.Title title=\"Navigate to 'Book' Screen\" /&gt;\n        &lt;Card.Content&gt;\n          &lt;Button mode=\"contained\" onPress={() =&gt; navigation.navigate('Book')}&gt;\n            Navigate\n          &lt;/Button&gt;\n        &lt;/Card.Content&gt;\n      &lt;/Card&gt;\n    &lt;/ScrollView&gt;\n  )</code></pre><p>You change the title of the card to \"Navigate to 'Book' Screen\". Then, inside the content of the card, you add a <a href=\"https://callstack.github.io/react-native-paper/button.html\">Button</a> component with <code>onPress</code> listener. This listener will be executed when the user presses on the button.</p><p>Inside the listener, you use the <code>navigation</code> prop to navigate to the <code>Book</code> screen using the method <code>navigate</code>. The method <code>navigate</code> takes the name of the route to navigate to.</p><p>Let's test it out. Run the app again if it isn't running. You should see a new button on the Home screen.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/12/IMG_1543.PNG\" class=\"kg-image\" alt loading=\"lazy\" width=\"1170\" height=\"2532\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1543.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1543.PNG 1000w, https://backend.shahednasser.com/content/images/2021/12/IMG_1543.PNG 1170w\" sizes=\"(min-width: 720px) 720px\"></figure><p>Try clicking on the <code>Navigate</code> button. You'll be navigated to the <code>BookScreen</code>.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/12/IMG_1544.PNG\" class=\"kg-image\" alt loading=\"lazy\" width=\"1170\" height=\"2532\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1544.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1544.PNG 1000w, https://backend.shahednasser.com/content/images/2021/12/IMG_1544.PNG 1170w\" sizes=\"(min-width: 720px) 720px\"></figure><p>Notice how the back button in the navigation bar is added automatically when you navigate to another screen. You can use it to go back to the previous screen, which is in this case the Home screen.</p><h2 id=\"navigate-with-parameters\">Navigate with Parameters</h2><p>In a lot of cases, you'll need to navigate to another screen and pass it parameters. In this section, you'll create an input that allows the user to enter their name, then when they submit you'll open a new screen called <code>NameScreen</code> which will show a greeting to the user with the name they entered.</p><p>Start by adding a new state variable to hold the value of the input you'll add soon in <code>HomeScreen.js</code>:</p><pre><code class=\"language-js\">const [name, setName] = useState('');</code></pre><p>Make sure to add an import for <code>useState</code> at the beginning of the file:</p><pre><code class=\"language-js\">import React, { useState } from 'react';</code></pre><p>Then, add a new Card component below the existing one:</p><pre><code class=\"language-js\">&lt;Card style={styles.card}&gt;\n    &lt;Card.Title title=\"Navigate with Parameters\" /&gt;\n    &lt;Card.Content&gt;\n        &lt;TextInput mode=\"outlined\" label=\"Name\" value={name} onChangeText={(text) =&gt; setName(text)} style={styles.textInput} /&gt;\n            &lt;Button mode=\"contained\" disabled={name.length === 0} onPress={() =&gt; navigation.navigate('Name', { name })}&gt;\n                Navigate\n    \t&lt;/Button&gt;\n    &lt;/Card.Content&gt;\n&lt;/Card&gt;</code></pre><p>This new card has a <a href=\"https://callstack.github.io/react-native-paper/text-input.html\">TextInput</a> with the value <code>name</code>, and on the <code>onChangeText</code> event, which occurs when the user makes changes to the text inside the input, you change the value of the <code>name</code> state variable.</p><p>Below the input, you have a button that is disabled when the <code>name</code> state variable is empty. You also add an <code>onPress</code> event listener which navigates the user to the <code>Name</code> route. </p><p>Notice that you're using the same <code>navigation.navigate</code> method that you used before to navigate to the \"Book\" route, however, this time you pass a second parameter to the method. This method accepts as a second parameter an object of parameters you want to pass. Here, you pass the <code>name</code> variable inside the object.</p><p>One last thing you need to do in the <code>HomeScreen</code> is change the <code>styles</code> object to the following:</p><pre><code class=\"language-js\">const styles = StyleSheet.create({\n  scrollView: {\n    backgroundColor: DefaultTheme.colors.background,\n    paddingTop: 10\n  },\n  card: {\n    width: '90%',\n    marginLeft: 'auto',\n    marginRight: 'auto',\n    marginBottom: 10\n  },\n  textInput: {\n    marginBottom: 10\n  }\n});</code></pre><p>This just makes some changes to the <code>card</code> property and adds a new property <code>textInput</code>.</p><p>You'll now create the <code>NameScreen</code> which will be the component for the \"Name\" route you'll add soon. Create <code>screens/NameScreen.js</code> with the following content:</p><pre><code class=\"language-js\">import React from 'react';\nimport { StyleSheet, View } from 'react-native';\nimport { Card } from 'react-native-paper';\nimport { DefaultTheme } from 'react-native-paper';\n\nfunction NameScreen ({ route }) {\n  const { name } = route.params;\n\n  return (\n    &lt;View style={styles.container}&gt;\n      &lt;Card style={styles.card}&gt;\n        &lt;Card.Title title={`Hello, ${name}`} /&gt;\n      &lt;/Card&gt;\n    &lt;/View&gt;\n  );\n}\n\nconst styles = StyleSheet.create({\n  container: {\n    flex: 1,\n    flexDirection: 'column',\n    backgroundColor: DefaultTheme.colors.background,\n    alignItems: 'center',\n    paddingTop: 10\n  },\n  card: {\n    width: '90%'\n  }\n});\n\nexport default NameScreen;</code></pre><p>This screen is essentially the same as <code>BookScreen</code>, however, notice the <code>route</code> prop passed to the function.</p><p>As mentioned before, the components inside the navigation stack receive a <code>navigation</code> prop to navigate between screens. They also receive a <code>route</code> prop which you can use to get the parameters passed to the screen using <code>route.params</code>.</p><p>So, in <code>NameScreen</code>, you retrieve the value entered in the <code>Name</code> input in the <code>HomeScreen</code>, which is passed when navigating to the <code>NameScreen</code> when the button is clicked using <code>route.params</code>:</p><pre><code class=\"language-js\">const { name } = route.params;</code></pre><p>You then show the user a greeting inside a card using the name parameter.</p><p>One last thing left to do is add the \"Name\" route to the navigation stack. Add a new <code>&lt;Stack.Screen&gt;</code> below the previous ones in <code>App.js</code>:</p><pre><code class=\"language-js\">&lt;Stack.Screen name=\"Name\" component={NameScreen} /&gt;</code></pre><p>And import <code>NameScreen</code> below other imports at the beginning of the file:</p><pre><code class=\"language-js\">import NameScreen from './screens/NameScreen';</code></pre><p>Let's test it out. Run the app if it isn't already running. You'll see that there's a new card on the Home screen with an input and a button.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/12/IMG_1546.PNG\" class=\"kg-image\" alt loading=\"lazy\" width=\"1170\" height=\"2532\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1546.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1546.PNG 1000w, https://backend.shahednasser.com/content/images/2021/12/IMG_1546.PNG 1170w\" sizes=\"(min-width: 720px) 720px\"></figure><p>Try entering your name, then click the \"Navigate\" button below the input. You'll be navigated to the <code>NameScreen</code> and you'll see your name.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/12/IMG_1547.PNG\" class=\"kg-image\" alt loading=\"lazy\" width=\"1170\" height=\"2532\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1547.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1547.PNG 1000w, https://backend.shahednasser.com/content/images/2021/12/IMG_1547.PNG 1170w\" sizes=\"(min-width: 720px) 720px\"></figure><p>You can try going back then changing the value of the name. The name in the <code>NameScreen</code> will change accordingly.</p><h2 id=\"configure-the-header\">Configure the Header</h2><h3 id=\"change-the-title\">Change the title</h3><p>Sometimes, you want the title of a route to be different than the name of the route, or you want the title to be dynamic based on a parameter passed or some other logic.</p><p>In this section, you'll add a new input in <code>HomeScreen</code> that will let you to enter a title, then on clicking the navigate button you'll be navigated to a new screen <code>TitleScreen</code>, whose title will change based on the title entered in the input in HomeScreen.</p><p>Start by adding a new state variable in <code>HomeScreen.js</code> to store the title:</p><pre><code class=\"language-js\">const [title, setTitle] = useState('');</code></pre><p>Then, add a new card below the previous cards:</p><pre><code class=\"language-js\">&lt;Card style={styles.card}&gt;\n        &lt;Card.Title title=\"Navigate to Route with Title\" /&gt;\n        &lt;Card.Content&gt;\n          &lt;TextInput mode=\"outlined\" label=\"Title\" value={title} onChangeText={(text) =&gt; setTitle(text)} style={styles.textInput} /&gt;\n          &lt;Button mode=\"contained\" disabled={title.length === 0} onPress={() =&gt; navigation.navigate('Title', { title })}&gt;\n            Navigate\n          &lt;/Button&gt;\n        &lt;/Card.Content&gt;\n      &lt;/Card&gt;</code></pre><p>This is pretty much the same as the card we added in the previous section. The only difference is that it uses the <code>title</code> state variable, and the listener for <code>onPress</code> for the button navigates to the route \"Title\", passing the <code>title</code> as a parameter.</p><p>Next, create the file <code>screens/Title.js</code> with the following content:</p><pre><code class=\"language-js\">import React from 'react';\nimport { StyleSheet, View } from 'react-native';\nimport { Card } from 'react-native-paper';\nimport { DefaultTheme } from 'react-native-paper';\n\nfunction TitleScreen () {\n  return (\n    &lt;View style={styles.container}&gt;\n      &lt;Card style={styles.card}&gt;\n        &lt;Card.Title title=\"This is title screen\" /&gt;\n      &lt;/Card&gt;\n    &lt;/View&gt;\n  );\n}\n\nconst styles = StyleSheet.create({\n  container: {\n    flex: 1,\n    flexDirection: 'column',\n    backgroundColor: DefaultTheme.colors.background,\n    alignItems: 'center',\n    paddingTop: 10\n  },\n  card: {\n    width: '90%'\n  }\n});\n\nexport default TitleScreen;</code></pre><p>This screen has nothing special. It just shows a card with the title \"This is title screen\". It doesn't even use the title parameter.</p><p>That's because you can change the title of a screen by passing an <code>options</code> parameter to <code>&lt;Stack.Screen&gt;</code> when adding the route.</p><p>In <code>App.js</code>, add an import for <code>TitleScreen</code> below other imports at the beginning of the file:</p><pre><code class=\"language-js\">import TitleScreen from './screens/TitleScreen';</code></pre><p>Then, add the new route below previous <code>&lt;Stack.Screen&gt;</code>:</p><pre><code class=\"language-js\">&lt;Stack.Screen name=\"Title\" component={TitleScreen} options={({route}) =&gt; ({title: route.params.title})} /&gt;</code></pre><p>Every <code>Stack.Screen</code> component can take an <code>options</code> prop. The <code>options</code> prop can be an object like so:</p><pre><code class=\"language-js\">options={{title: \"Hello\"}}</code></pre><p>This is enough if your options are static. However, if the value for any of the options is dynamic, like in this example, you can instead pass it a function that returns an object. This function can receive as a parameter <code>route</code>, which is similar to the <code>route</code> parameter you used in <code>NameScreen</code>:</p><pre><code class=\"language-js\">options={({route}) =&gt; ({title: route.params.title})}</code></pre><p>In this function, you return an object that has a <code>title</code> property with the value <code>route.params.title</code>. So, when the user enters a title in the input and clicks on the Navigate button, the title will be passed to the route, which will change the title of \"Title\" route using the function passed to the <code>options</code> prop.</p><p>Let's test it out. Run the app if it's not running already. You should see a new card on the Home screen with a new input:</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/12/IMG_1548.PNG\" class=\"kg-image\" alt loading=\"lazy\" width=\"1170\" height=\"2532\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1548.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1548.PNG 1000w, https://backend.shahednasser.com/content/images/2021/12/IMG_1548.PNG 1170w\" sizes=\"(min-width: 720px) 720px\"></figure><p>Try entering any title you want in the input then click on Navigate. You'll see that you'll be navigated to the <code>TitleScreen</code>, but the title will be the value you entered in the input.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/12/IMG_1549.PNG\" class=\"kg-image\" alt loading=\"lazy\" width=\"1170\" height=\"2532\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1549.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1549.PNG 1000w, https://backend.shahednasser.com/content/images/2021/12/IMG_1549.PNG 1170w\" sizes=\"(min-width: 720px) 720px\"></figure><p>You can try going back then changing the value entered in the input. The title of the screen will change accordingly.</p><h3 id=\"add-header-button\">Add Header Button</h3><p>Another option you can add is header buttons. You can customize what your header shows on the left and right by using the <code>headerRight</code> and <code>headerLeft</code> properties in the <code>options</code> param of <code>&lt;Stack.Screen&gt;</code>.</p><p>In this section, you'll add a button to the right of the header of the Home screen which will show a user an alert when they click on it.</p><p>In <code>App.js</code>, add to the \"Home\" route a prop <code>option</code>:</p><pre><code class=\"language-js\">&lt;Stack.Screen name=\"Home\" component={HomeScreen} options={{\n            headerRight: () =&gt; (\n              &lt;IconButton icon=\"alert-outline\" onPress={() =&gt; alert('You\\'re awesome!')} color={DefaultTheme.colors.notification} /&gt;\n            )\n}} /&gt;</code></pre><p>In the <code>options</code> prop, you pass an object with the property <code>headerRight</code>. The <code>headerRight</code> property can be a component that you can render elements inside. You render an <a href=\"https://callstack.github.io/react-native-paper/icon-button.html\">IconButton</a> component, which is a button that only has an icon without text. In the <code>onPress</code> event listener, you show an alert to the user.</p><p>That's all. Run the app if it isn't running already. You'll see a new icon at the top right of the header in Home Screen.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/12/IMG_1550.PNG\" class=\"kg-image\" alt loading=\"lazy\" width=\"1170\" height=\"2532\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1550.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1550.PNG 1000w, https://backend.shahednasser.com/content/images/2021/12/IMG_1550.PNG 1170w\" sizes=\"(min-width: 720px) 720px\"></figure><p>Click on it and you'll see an alert.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/12/IMG_1551.PNG\" class=\"kg-image\" alt loading=\"lazy\" width=\"1170\" height=\"2532\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1551.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1551.PNG 1000w, https://backend.shahednasser.com/content/images/2021/12/IMG_1551.PNG 1170w\" sizes=\"(min-width: 720px) 720px\"></figure><h2 id=\"navigation-events\">Navigation Events</h2><p>In React Navigation, you can subscribe to two events: <code>focus</code> and <code>blur</code>. The <code>focus</code> event will occur every time the screen is opened and is currently the main screen. The <code>blur</code> event will occur whenever a screen was in focus but navigation occurs that makes the screen not the current main screen. Simply put, the <code>focus</code> event is when the screen is visible to the user, and the <code>blur</code> event occurs when a screen was visible to a user but isn't anymore. </p><p>In this section, you'll add a counter that will count how many times you navigated to other screens from the home screen. So, this counter will increment in the <code>blur</code> event.</p><p>To subscribe to events, in a <code>useEffect</code> callback inside a component, you can use <code>navigation.addListener</code> passing it the name of the event as a first parameter, and the event handler as a second parameter. The <code>addListener</code> method returns an unsubscribe function which you should return in the <code>useEffect</code> callback.</p><p>In <code>HomeScreen.js</code>, add an import for <code>useEffect</code> at the beginning of the file:</p><pre><code class=\"language-js\">import React, { useEffect, useState } from 'react';</code></pre><p>Then, add a new state variable <code>counter</code> inside the <code>HomeScreen</code> component:</p><pre><code class=\"language-js\">const [counter, setCounter] = useState(0);</code></pre><p>After that add the <code>useEffect</code> callback that will register the event handle for the <code>blur</code> event:</p><pre><code class=\"language-js\">useEffect(() =&gt; {\n    return navigation.addListener('blur', () =&gt; {\n      setCounter(counter + 1);\n    });\n  });</code></pre><p>As you can see, you use <code>navigation.addListener</code> to add an event listener to the <code>blur</code> event. The function passed as a second parameter is the handler of the event. It will be executed whenever the screen is out of focus (not the screen visible to the user). Inside the event handler, you increment the counter by 1.</p><p>Finally, you'll show the counter at the top of the screen. In <code>ScrollView</code>, add a new card before the previously added cards:</p><pre><code class=\"language-js\">&lt;Card style={styles.card}&gt;\n\t&lt;Card.Title title={`Navigation Count: ${counter}`} /&gt;\n&lt;/Card&gt;</code></pre><p>Let's test it out. Run the app if it's not already running. You should see a card with a count of navigation at the top of the screen.</p><h2 id=\"go-back\">Go Back</h2><p>The last thing you'll learn in this tutorial is how to go back to the previous screen. As you've seen throughout the tutorial, when you navigate to a screen you'll see a back button in the header which you can use to go back to the previous screen.</p><p>Although this is sufficient in most cases, sometimes you want to go back to the previous screen programmatically. You'll create in this section a new screen <code>BackScreen</code> which you can go to from the <code>HomeScreen</code>. This screen will have a back button in its content and when you click on it you can go back to the previous screen, which is the <code>HomeScreen</code>.</p><p>Create the file <code>screens/BackScreen.js</code> with the following content:</p><pre><code class=\"language-js\">import React from 'react';\nimport { StyleSheet, View } from 'react-native';\nimport { Button, Card } from 'react-native-paper';\nimport { DefaultTheme } from 'react-native-paper';\n\nfunction BackScreen ({ navigation }) {\n  return (\n    &lt;View style={styles.container}&gt;\n      &lt;Card style={styles.card}&gt;\n        &lt;Card.Title title=\"This is Back Screen\" /&gt;\n        &lt;Card.Content&gt;\n          &lt;Button mode=\"contained\" onPress={() =&gt; navigation.goBack()}&gt;\n            Go Back\n          &lt;/Button&gt;\n        &lt;/Card.Content&gt;\n      &lt;/Card&gt;\n    &lt;/View&gt;\n  );\n}\n\nconst styles = StyleSheet.create({\n  container: {\n    flex: 1,\n    flexDirection: 'column',\n    backgroundColor: DefaultTheme.colors.background,\n    alignItems: 'center',\n    paddingTop: 10\n  },\n  card: {\n    width: '90%'\n  }\n});\n\nexport default BackScreen;</code></pre><p>This screen is pretty much the same as other screens. The things you should note is that, first, the screen has uses the <code>navigation</code> prop that is passed to components inside the navigation stack. Second, the screen has a button inside a card which, on press, will use the <code>navigation</code> prop to go back using the <code>goBack</code> method:</p><pre><code class=\"language-js\">&lt;Button mode=\"contained\" onPress={() =&gt; navigation.goBack()}&gt;</code></pre><p>Now, go to the <code>HomeScreen</code> and add a new card at the end of the ScrollView:</p><pre><code class=\"language-js\">&lt;Card style={styles.card}&gt;\n    &lt;Card.Title title=\"Navigate to 'Back' Screen\" /&gt;\n    &lt;Card.Content&gt;\n        &lt;Button mode=\"contained\" onPress={() =&gt; navigation.navigate('Back')}&gt;\n            Navigate\n    \t&lt;/Button&gt;\n    &lt;/Card.Content&gt;\n&lt;/Card&gt;</code></pre><p>This card just shows a button to navigate to the route \"Back\". Let's add that route now.</p><p>In <code>App.js</code> add a new <code>&lt;Stack.Screen&gt;</code> component below the previously added ones:</p><pre><code class=\"language-js\">&lt;Stack.Screen name=\"Back\" component={BackScreen} /&gt;</code></pre><p>It's ready now. Run the app if it isn't already running. You'll see a new card at the end of the list.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/12/IMG_1554.PNG\" class=\"kg-image\" alt loading=\"lazy\" width=\"1170\" height=\"2532\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1554.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1554.PNG 1000w, https://backend.shahednasser.com/content/images/2021/12/IMG_1554.PNG 1170w\" sizes=\"(min-width: 720px) 720px\"></figure><p>Click on \"Navigate\" on the last card. You'll be navigated to the <code>BackScreen</code>.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/12/IMG_1555.PNG\" class=\"kg-image\" alt loading=\"lazy\" width=\"1170\" height=\"2532\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1555.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1555.PNG 1000w, https://backend.shahednasser.com/content/images/2021/12/IMG_1555.PNG 1170w\" sizes=\"(min-width: 720px) 720px\"></figure><p>Click on the \"Go Back\" button in the card. You'll be taken back to the <code>HomeScreen</code>.</p><h2 id=\"conclusion\">Conclusion</h2><p>In this tutorial, you learned how to use React Navigation to navigate between screens, pass a parameter from one screen to another, configure the header of a screen, add navigation event listeners, and go back programmatically to the previous screen.</p><p>Although this covers most use cases for using React Navigation, be sure to check out <a href=\"https://reactnavigation.org/docs/getting-started\">their documentation</a> for more details on how to use it. </p>","url":"https://backend.shahednasser.com/react-native-navigation-tutorial/","canonical_url":null,"uuid":"c0afd92e-2e0d-4a81-b5c5-d41dd2553877","codeinjection_foot":null,"codeinjection_head":null,"codeinjection_styles":null,"comment_id":"61b1cb7ad752820612f17bad","reading_time":15,"send_email_when_published":null,"email_subject":null,"childHtmlRehype":{"html":"<p><a href=\"https://reactnative.dev\">React Native</a> is one of the most popular cross-platform app development frameworks. Using JavaScript, you can develop native apps for both Android and iOS.</p><p>One important part of creating apps is being able to navigate between screens. In this tutorial, you'll learn how to use <a href=\"https://reactnavigation.org\">React Navigation</a> in your app to add navigation. This will include basic navigation from one screen to another, going back to the previous screen, passing parameters, listening to events, and more.</p><p>This tutorial will not explain the basics of creating a React Native app. If you're interested in learning about that, you can check out my other tutorial <a href=\"https://blog.shahednasser.com/react-native-tutorial-create-your-first-app\">React Native Tutorial: Create Your First App</a>.</p><p>You can find the code for this tutorial on <a href=\"https://github.com/shahednasser/react-navigation-tutorial\">this GitHub repository</a>.</p><h2 id=\"prerequisites\">Prerequisites </h2><p>Make sure you have both <a href=\"https://nodejs.org/en/\">Node.js</a> and NPM installed on your machine. You can check if they're installed with the following command:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">node</span> -v\n<span class=\"token function\">npm</span> -v</code></pre></div><p>If they're not installed, you can <a href=\"https://nodejs.org/en/\">install Node.js</a> and NPM will be installed automatically with it.</p><p> After that, make sure you install <a href=\"https://expo.dev\">Expo</a>'s CLI if you don't have it installed:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">npm</span> <span class=\"token function\">install</span> -g expo-cli</code></pre></div><p>If you're not familiar with what Expo is, Expo provides a set of tools built around React. Most importantly, it allows you to write and build your React Native app in minutes.</p><p>You should also install <a href=\"https://expo.dev/client\">Expo Go</a> on your device to be able to test the app as we go through the tutorial.</p><h2 id=\"project-setup\">Project Setup</h2><p>Start by creating a new React Native project using Expo's CLI:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">expo init react-navigation-tutorial —npm</code></pre></div><p>You'll be then prompted to choose the type of app, choose \"blank\".</p><p>After that the <code class=\"language-text\">init</code> command will install the dependencies you need for your React Native project.</p><p>Once it's done, change to the directory of the project:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token builtin class-name\">cd</span> react-navigation-tutorial</code></pre></div><p>Now, you'll install the dependencies required to use React Navigation. First, install the building blocks libraries using Expo's CLI with the following command:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">expo <span class=\"token function\">install</span> react-native-screens react-native-safe-area-context</code></pre></div><p>Second, install the native stack navigator library:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">npm</span> <span class=\"token function\">install</span> @react-navigation/native-stack</code></pre></div><p>Now, you have all the libraries required to start using React Navigation.</p><p>Finally, install <a href=\"https://callstack.github.io/react-native-paper/index.html\">React Native Paper</a> to have beautifully-styled components in your app:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">npm</span> <span class=\"token function\">install</span> react-native-paper</code></pre></div><h2 id=\"set-up-react-navigation\">Set Up React Navigation</h2><p>Before you can start adding routes to your app, you need to create a Stack Navigator. This stack navigator will be used to create screens and navigate between them.</p><p>In <code class=\"language-text\">App.js</code>, change the content to the following:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">import</span> React <span class=\"token keyword\">from</span> <span class=\"token string\">'react'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> NavigationContainer <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'@react-navigation/native'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> createNativeStackNavigator <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'@react-navigation/native-stack'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> Provider <span class=\"token keyword\">as</span> PaperProvider <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native-paper'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> HomeScreen <span class=\"token keyword\">from</span> <span class=\"token string\">'./screens/HomeScreen'</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">const</span> Stack <span class=\"token operator\">=</span> <span class=\"token function\">createNativeStackNavigator</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span>\n\n<span class=\"token keyword\">export</span> <span class=\"token keyword\">default</span> <span class=\"token keyword\">function</span> <span class=\"token function\">App</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token keyword\">return</span> <span class=\"token punctuation\">(</span>\n    <span class=\"token operator\">&#x3C;</span>PaperProvider<span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span>NavigationContainer<span class=\"token operator\">></span>\n        <span class=\"token operator\">&#x3C;</span>Stack<span class=\"token punctuation\">.</span>Navigator<span class=\"token operator\">></span>\n          <span class=\"token operator\">&#x3C;</span>Stack<span class=\"token punctuation\">.</span>Screen name<span class=\"token operator\">=</span><span class=\"token string\">\"Home\"</span> component<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>HomeScreen<span class=\"token punctuation\">}</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n        <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Stack<span class=\"token punctuation\">.</span>Navigator<span class=\"token operator\">></span>\n    <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>NavigationContainer<span class=\"token operator\">></span>\n    <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>PaperProvider<span class=\"token operator\">></span>\n  <span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span>\n</code></pre></div><p>Notice that in the returned value of <code class=\"language-text\">App</code>, you first have <code class=\"language-text\">&#x3C;PaperProvider></code> at the top of the elements. This is just used to make sure all screens share the same theme.</p><p>Next, you have the <code class=\"language-text\">&#x3C;NavigationContainer></code>. This component manages the navigation tree and contains the navigation state. So, it should wrap Stack navigators.</p><p>Inside <code class=\"language-text\">&#x3C;NavigationContainer></code> you have <code class=\"language-text\">&#x3C;Stack.Navigator></code>. <code class=\"language-text\">Stack</code> is created using <code class=\"language-text\">createNativeStackNavigator</code>. This function returns an object containing 2 properties: <code class=\"language-text\">Screen</code> and <code class=\"language-text\">Navigator</code>. The <code class=\"language-text\">Navigator</code> property is a React element and it should be used to wrap the <code class=\"language-text\">Screen</code> elements to manage routing configurations.</p><p>So, inside <code class=\"language-text\">&#x3C;Stack.Navigator></code> you'll have one or more <code class=\"language-text\">&#x3C;Stack.Screen></code> components. For each route, you'll have a <code class=\"language-text\">&#x3C;Stack.Screen></code> component. Now, you just have one component that points to the <code class=\"language-text\">Home</code> route.</p><p>Notice that a <code class=\"language-text\">Screen</code> component takes the <code class=\"language-text\">name</code> prop, which is the name of the route and will be referenced later on when navigating to this route, and the <code class=\"language-text\">component</code> property which is the component to render for this route.</p><p>As you can see, you're passing <code class=\"language-text\">HomeScreen</code> component to the <code class=\"language-text\">Home</code> route, so you need to create it now.</p><p>Create the directory <code class=\"language-text\">screens</code>, and inside that directory create a new file <code class=\"language-text\">HomeScreen.js</code> with the following content:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">import</span> React <span class=\"token keyword\">from</span> <span class=\"token string\">'react'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> ScrollView<span class=\"token punctuation\">,</span> StyleSheet <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> Button<span class=\"token punctuation\">,</span> Card <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native-paper'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> DefaultTheme <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native-paper'</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">function</span> <span class=\"token function\">HomeScreen</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token keyword\">return</span> <span class=\"token punctuation\">(</span>\n    <span class=\"token operator\">&#x3C;</span>ScrollView style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>styles<span class=\"token punctuation\">.</span>scrollView<span class=\"token punctuation\">}</span><span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span>Card style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>styles<span class=\"token punctuation\">.</span>card<span class=\"token punctuation\">}</span><span class=\"token operator\">></span>\n        <span class=\"token operator\">&#x3C;</span>Card<span class=\"token punctuation\">.</span>Title title<span class=\"token operator\">=</span><span class=\"token string\">\"Home Screen\"</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Card<span class=\"token operator\">></span>\n    <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>ScrollView<span class=\"token operator\">></span>\n  <span class=\"token punctuation\">)</span>\n<span class=\"token punctuation\">}</span>\n\n<span class=\"token keyword\">const</span> styles <span class=\"token operator\">=</span> StyleSheet<span class=\"token punctuation\">.</span><span class=\"token function\">create</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\n  <span class=\"token literal-property property\">scrollView</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token literal-property property\">backgroundColor</span><span class=\"token operator\">:</span> DefaultTheme<span class=\"token punctuation\">.</span>colors<span class=\"token punctuation\">.</span>background<span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">paddingTop</span><span class=\"token operator\">:</span> <span class=\"token number\">10</span>\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n  <span class=\"token literal-property property\">card</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token literal-property property\">width</span><span class=\"token operator\">:</span> <span class=\"token string\">'90%'</span><span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">marginLeft</span><span class=\"token operator\">:</span> <span class=\"token string\">'auto'</span><span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">marginRight</span><span class=\"token operator\">:</span> <span class=\"token string\">'auto'</span>\n  <span class=\"token punctuation\">}</span>\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">export</span> <span class=\"token keyword\">default</span> HomeScreen</code></pre></div><p>This will create a basic home screen with a <a href=\"https://reactnative.dev/docs/scrollview\">ScrollView</a> component containing a <a href=\"https://callstack.github.io/react-native-paper/card.html\">Card</a> component with the title \"Home Screen\".</p><p>You just created your first route with React Navigation! Let's test it out.</p><p>In your terminal run to start your app:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">npm</span> start</code></pre></div><p>Then, you'll be able to run the app on Expo Go on your phone by scanning the QR code on the Expo Go app on Android or on the Camera app on iOS.</p><p>Once the app run, you'll see the Home screen that you created as it's the default and only route.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/12/IMG_1545.PNG\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"1170\" height=\"2532\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1545.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1545.PNG 1000w, https://backend.shahednasser.com/content/images/2021/12/IMG_1545.PNG 1170w\" sizes=\"(min-width: 720px) 720px\"></figure><h2 id=\"navigate-to-another-screen\">Navigate to Another Screen</h2><p>In this section, you'll learn how to navigate from one screen to another.</p><p>Screens that are inside the Stack Navigation, like HomeScreen in this app, receive a <code class=\"language-text\">navigation</code> prop. This prop allows us to navigate to other screens in the app.</p><p>Let's first create the screen you'll navigate to. Create the file <code class=\"language-text\">screens/BookScreen.js</code> with the following content:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">import</span> React <span class=\"token keyword\">from</span> <span class=\"token string\">'react'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> StyleSheet<span class=\"token punctuation\">,</span> View <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> Card <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native-paper'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> DefaultTheme <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native-paper'</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">function</span> <span class=\"token function\">BookScreen</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token keyword\">return</span> <span class=\"token punctuation\">(</span>\n    <span class=\"token operator\">&#x3C;</span>View style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>styles<span class=\"token punctuation\">.</span>container<span class=\"token punctuation\">}</span><span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span>Card style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>styles<span class=\"token punctuation\">.</span>card<span class=\"token punctuation\">}</span><span class=\"token operator\">></span>\n        <span class=\"token operator\">&#x3C;</span>Card<span class=\"token punctuation\">.</span>Title title<span class=\"token operator\">=</span><span class=\"token string\">\"This is Books Screen\"</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Card<span class=\"token operator\">></span>\n    <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>View<span class=\"token operator\">></span>\n  <span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span>\n\n<span class=\"token keyword\">const</span> styles <span class=\"token operator\">=</span> StyleSheet<span class=\"token punctuation\">.</span><span class=\"token function\">create</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\n  <span class=\"token literal-property property\">container</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token literal-property property\">flex</span><span class=\"token operator\">:</span> <span class=\"token number\">1</span><span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">flexDirection</span><span class=\"token operator\">:</span> <span class=\"token string\">'column'</span><span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">backgroundColor</span><span class=\"token operator\">:</span> DefaultTheme<span class=\"token punctuation\">.</span>colors<span class=\"token punctuation\">.</span>background<span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">alignItems</span><span class=\"token operator\">:</span> <span class=\"token string\">'center'</span><span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">paddingTop</span><span class=\"token operator\">:</span> <span class=\"token number\">10</span>\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n  <span class=\"token literal-property property\">card</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token literal-property property\">width</span><span class=\"token operator\">:</span> <span class=\"token string\">'90%'</span>\n  <span class=\"token punctuation\">}</span>\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">export</span> <span class=\"token keyword\">default</span> BookScreen<span class=\"token punctuation\">;</span></code></pre></div><p>This screen is similar to <code class=\"language-text\">HomeScreen</code>. It just shows a card with the title \"This is Books Screen\".</p><p>Next, add the new route in <code class=\"language-text\">App.js</code> for <code class=\"language-text\">BookScreen</code> below the \"Home\" route:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token operator\">&#x3C;</span>Stack<span class=\"token punctuation\">.</span>Screen name<span class=\"token operator\">=</span><span class=\"token string\">\"Book\"</span> component<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>BookScreen<span class=\"token punctuation\">}</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span></code></pre></div><p>Don't forget to import <code class=\"language-text\">BookScreen</code> below the imports at the beginning of <code class=\"language-text\">App.js</code>:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">import</span> BookScreen <span class=\"token keyword\">from</span> <span class=\"token string\">'./screens/BookScreen'</span><span class=\"token punctuation\">;</span></code></pre></div><p>Now, you can navigate to the \"Book\" route inside this stack navigation. To see how it works, you'll add a button in <code class=\"language-text\">HomeScreen</code> that when the user clicks will navigate to <code class=\"language-text\">BookScreen</code>.</p><p>In <code class=\"language-text\">HomeScreen</code>, add the <code class=\"language-text\">navigation</code> prop to the function:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">function</span> <span class=\"token function\">HomeScreen</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\"><span class=\"token punctuation\">{</span> navigation <span class=\"token punctuation\">}</span></span><span class=\"token punctuation\">)</span></code></pre></div><p>Then, change the returned value of the function to the following:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">return</span> <span class=\"token punctuation\">(</span>\n    <span class=\"token operator\">&#x3C;</span>ScrollView style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>styles<span class=\"token punctuation\">.</span>scrollView<span class=\"token punctuation\">}</span><span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span>Card style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>styles<span class=\"token punctuation\">.</span>card<span class=\"token punctuation\">}</span><span class=\"token operator\">></span>\n        <span class=\"token operator\">&#x3C;</span>Card<span class=\"token punctuation\">.</span>Title title<span class=\"token operator\">=</span><span class=\"token string\">\"Navigate to 'Book' Screen\"</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n        <span class=\"token operator\">&#x3C;</span>Card<span class=\"token punctuation\">.</span>Content<span class=\"token operator\">></span>\n          <span class=\"token operator\">&#x3C;</span>Button mode<span class=\"token operator\">=</span><span class=\"token string\">\"contained\"</span> onPress<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> navigation<span class=\"token punctuation\">.</span><span class=\"token function\">navigate</span><span class=\"token punctuation\">(</span><span class=\"token string\">'Book'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">}</span><span class=\"token operator\">></span>\n            Navigate\n          <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Button<span class=\"token operator\">></span>\n        <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Card<span class=\"token punctuation\">.</span>Content<span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Card<span class=\"token operator\">></span>\n    <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>ScrollView<span class=\"token operator\">></span>\n  <span class=\"token punctuation\">)</span></code></pre></div><p>You change the title of the card to \"Navigate to 'Book' Screen\". Then, inside the content of the card, you add a <a href=\"https://callstack.github.io/react-native-paper/button.html\">Button</a> component with <code class=\"language-text\">onPress</code> listener. This listener will be executed when the user presses on the button.</p><p>Inside the listener, you use the <code class=\"language-text\">navigation</code> prop to navigate to the <code class=\"language-text\">Book</code> screen using the method <code class=\"language-text\">navigate</code>. The method <code class=\"language-text\">navigate</code> takes the name of the route to navigate to.</p><p>Let's test it out. Run the app again if it isn't running. You should see a new button on the Home screen.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/12/IMG_1543.PNG\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"1170\" height=\"2532\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1543.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1543.PNG 1000w, https://backend.shahednasser.com/content/images/2021/12/IMG_1543.PNG 1170w\" sizes=\"(min-width: 720px) 720px\"></figure><p>Try clicking on the <code class=\"language-text\">Navigate</code> button. You'll be navigated to the <code class=\"language-text\">BookScreen</code>.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/12/IMG_1544.PNG\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"1170\" height=\"2532\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1544.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1544.PNG 1000w, https://backend.shahednasser.com/content/images/2021/12/IMG_1544.PNG 1170w\" sizes=\"(min-width: 720px) 720px\"></figure><p>Notice how the back button in the navigation bar is added automatically when you navigate to another screen. You can use it to go back to the previous screen, which is in this case the Home screen.</p><h2 id=\"navigate-with-parameters\">Navigate with Parameters</h2><p>In a lot of cases, you'll need to navigate to another screen and pass it parameters. In this section, you'll create an input that allows the user to enter their name, then when they submit you'll open a new screen called <code class=\"language-text\">NameScreen</code> which will show a greeting to the user with the name they entered.</p><p>Start by adding a new state variable to hold the value of the input you'll add soon in <code class=\"language-text\">HomeScreen.js</code>:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">const</span> <span class=\"token punctuation\">[</span>name<span class=\"token punctuation\">,</span> setName<span class=\"token punctuation\">]</span> <span class=\"token operator\">=</span> <span class=\"token function\">useState</span><span class=\"token punctuation\">(</span><span class=\"token string\">''</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div><p>Make sure to add an import for <code class=\"language-text\">useState</code> at the beginning of the file:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">import</span> React<span class=\"token punctuation\">,</span> <span class=\"token punctuation\">{</span> useState <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react'</span><span class=\"token punctuation\">;</span></code></pre></div><p>Then, add a new Card component below the existing one:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token operator\">&#x3C;</span>Card style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>styles<span class=\"token punctuation\">.</span>card<span class=\"token punctuation\">}</span><span class=\"token operator\">></span>\n    <span class=\"token operator\">&#x3C;</span>Card<span class=\"token punctuation\">.</span>Title title<span class=\"token operator\">=</span><span class=\"token string\">\"Navigate with Parameters\"</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n    <span class=\"token operator\">&#x3C;</span>Card<span class=\"token punctuation\">.</span>Content<span class=\"token operator\">></span>\n        <span class=\"token operator\">&#x3C;</span>TextInput mode<span class=\"token operator\">=</span><span class=\"token string\">\"outlined\"</span> label<span class=\"token operator\">=</span><span class=\"token string\">\"Name\"</span> value<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>name<span class=\"token punctuation\">}</span> onChangeText<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">text</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token function\">setName</span><span class=\"token punctuation\">(</span>text<span class=\"token punctuation\">)</span><span class=\"token punctuation\">}</span> style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>styles<span class=\"token punctuation\">.</span>textInput<span class=\"token punctuation\">}</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n            <span class=\"token operator\">&#x3C;</span>Button mode<span class=\"token operator\">=</span><span class=\"token string\">\"contained\"</span> disabled<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>name<span class=\"token punctuation\">.</span>length <span class=\"token operator\">===</span> <span class=\"token number\">0</span><span class=\"token punctuation\">}</span> onPress<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> navigation<span class=\"token punctuation\">.</span><span class=\"token function\">navigate</span><span class=\"token punctuation\">(</span><span class=\"token string\">'Name'</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">{</span> name <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">}</span><span class=\"token operator\">></span>\n                Navigate\n    \t<span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Button<span class=\"token operator\">></span>\n    <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Card<span class=\"token punctuation\">.</span>Content<span class=\"token operator\">></span>\n<span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Card<span class=\"token operator\">></span></code></pre></div><p>This new card has a <a href=\"https://callstack.github.io/react-native-paper/text-input.html\">TextInput</a> with the value <code class=\"language-text\">name</code>, and on the <code class=\"language-text\">onChangeText</code> event, which occurs when the user makes changes to the text inside the input, you change the value of the <code class=\"language-text\">name</code> state variable.</p><p>Below the input, you have a button that is disabled when the <code class=\"language-text\">name</code> state variable is empty. You also add an <code class=\"language-text\">onPress</code> event listener which navigates the user to the <code class=\"language-text\">Name</code> route. </p><p>Notice that you're using the same <code class=\"language-text\">navigation.navigate</code> method that you used before to navigate to the \"Book\" route, however, this time you pass a second parameter to the method. This method accepts as a second parameter an object of parameters you want to pass. Here, you pass the <code class=\"language-text\">name</code> variable inside the object.</p><p>One last thing you need to do in the <code class=\"language-text\">HomeScreen</code> is change the <code class=\"language-text\">styles</code> object to the following:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">const</span> styles <span class=\"token operator\">=</span> StyleSheet<span class=\"token punctuation\">.</span><span class=\"token function\">create</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\n  <span class=\"token literal-property property\">scrollView</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token literal-property property\">backgroundColor</span><span class=\"token operator\">:</span> DefaultTheme<span class=\"token punctuation\">.</span>colors<span class=\"token punctuation\">.</span>background<span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">paddingTop</span><span class=\"token operator\">:</span> <span class=\"token number\">10</span>\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n  <span class=\"token literal-property property\">card</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token literal-property property\">width</span><span class=\"token operator\">:</span> <span class=\"token string\">'90%'</span><span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">marginLeft</span><span class=\"token operator\">:</span> <span class=\"token string\">'auto'</span><span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">marginRight</span><span class=\"token operator\">:</span> <span class=\"token string\">'auto'</span><span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">marginBottom</span><span class=\"token operator\">:</span> <span class=\"token number\">10</span>\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n  <span class=\"token literal-property property\">textInput</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token literal-property property\">marginBottom</span><span class=\"token operator\">:</span> <span class=\"token number\">10</span>\n  <span class=\"token punctuation\">}</span>\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div><p>This just makes some changes to the <code class=\"language-text\">card</code> property and adds a new property <code class=\"language-text\">textInput</code>.</p><p>You'll now create the <code class=\"language-text\">NameScreen</code> which will be the component for the \"Name\" route you'll add soon. Create <code class=\"language-text\">screens/NameScreen.js</code> with the following content:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">import</span> React <span class=\"token keyword\">from</span> <span class=\"token string\">'react'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> StyleSheet<span class=\"token punctuation\">,</span> View <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> Card <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native-paper'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> DefaultTheme <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native-paper'</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">function</span> <span class=\"token function\">NameScreen</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\"><span class=\"token punctuation\">{</span> route <span class=\"token punctuation\">}</span></span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token keyword\">const</span> <span class=\"token punctuation\">{</span> name <span class=\"token punctuation\">}</span> <span class=\"token operator\">=</span> route<span class=\"token punctuation\">.</span>params<span class=\"token punctuation\">;</span>\n\n  <span class=\"token keyword\">return</span> <span class=\"token punctuation\">(</span>\n    <span class=\"token operator\">&#x3C;</span>View style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>styles<span class=\"token punctuation\">.</span>container<span class=\"token punctuation\">}</span><span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span>Card style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>styles<span class=\"token punctuation\">.</span>card<span class=\"token punctuation\">}</span><span class=\"token operator\">></span>\n        <span class=\"token operator\">&#x3C;</span>Card<span class=\"token punctuation\">.</span>Title title<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token string\">Hello, </span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${</span>name<span class=\"token interpolation-punctuation punctuation\">}</span></span><span class=\"token template-punctuation string\">`</span></span><span class=\"token punctuation\">}</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Card<span class=\"token operator\">></span>\n    <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>View<span class=\"token operator\">></span>\n  <span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span>\n\n<span class=\"token keyword\">const</span> styles <span class=\"token operator\">=</span> StyleSheet<span class=\"token punctuation\">.</span><span class=\"token function\">create</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\n  <span class=\"token literal-property property\">container</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token literal-property property\">flex</span><span class=\"token operator\">:</span> <span class=\"token number\">1</span><span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">flexDirection</span><span class=\"token operator\">:</span> <span class=\"token string\">'column'</span><span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">backgroundColor</span><span class=\"token operator\">:</span> DefaultTheme<span class=\"token punctuation\">.</span>colors<span class=\"token punctuation\">.</span>background<span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">alignItems</span><span class=\"token operator\">:</span> <span class=\"token string\">'center'</span><span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">paddingTop</span><span class=\"token operator\">:</span> <span class=\"token number\">10</span>\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n  <span class=\"token literal-property property\">card</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token literal-property property\">width</span><span class=\"token operator\">:</span> <span class=\"token string\">'90%'</span>\n  <span class=\"token punctuation\">}</span>\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">export</span> <span class=\"token keyword\">default</span> NameScreen<span class=\"token punctuation\">;</span></code></pre></div><p>This screen is essentially the same as <code class=\"language-text\">BookScreen</code>, however, notice the <code class=\"language-text\">route</code> prop passed to the function.</p><p>As mentioned before, the components inside the navigation stack receive a <code class=\"language-text\">navigation</code> prop to navigate between screens. They also receive a <code class=\"language-text\">route</code> prop which you can use to get the parameters passed to the screen using <code class=\"language-text\">route.params</code>.</p><p>So, in <code class=\"language-text\">NameScreen</code>, you retrieve the value entered in the <code class=\"language-text\">Name</code> input in the <code class=\"language-text\">HomeScreen</code>, which is passed when navigating to the <code class=\"language-text\">NameScreen</code> when the button is clicked using <code class=\"language-text\">route.params</code>:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">const</span> <span class=\"token punctuation\">{</span> name <span class=\"token punctuation\">}</span> <span class=\"token operator\">=</span> route<span class=\"token punctuation\">.</span>params<span class=\"token punctuation\">;</span></code></pre></div><p>You then show the user a greeting inside a card using the name parameter.</p><p>One last thing left to do is add the \"Name\" route to the navigation stack. Add a new <code class=\"language-text\">&#x3C;Stack.Screen></code> below the previous ones in <code class=\"language-text\">App.js</code>:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token operator\">&#x3C;</span>Stack<span class=\"token punctuation\">.</span>Screen name<span class=\"token operator\">=</span><span class=\"token string\">\"Name\"</span> component<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>NameScreen<span class=\"token punctuation\">}</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span></code></pre></div><p>And import <code class=\"language-text\">NameScreen</code> below other imports at the beginning of the file:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">import</span> NameScreen <span class=\"token keyword\">from</span> <span class=\"token string\">'./screens/NameScreen'</span><span class=\"token punctuation\">;</span></code></pre></div><p>Let's test it out. Run the app if it isn't already running. You'll see that there's a new card on the Home screen with an input and a button.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/12/IMG_1546.PNG\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"1170\" height=\"2532\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1546.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1546.PNG 1000w, https://backend.shahednasser.com/content/images/2021/12/IMG_1546.PNG 1170w\" sizes=\"(min-width: 720px) 720px\"></figure><p>Try entering your name, then click the \"Navigate\" button below the input. You'll be navigated to the <code class=\"language-text\">NameScreen</code> and you'll see your name.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/12/IMG_1547.PNG\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"1170\" height=\"2532\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1547.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1547.PNG 1000w, https://backend.shahednasser.com/content/images/2021/12/IMG_1547.PNG 1170w\" sizes=\"(min-width: 720px) 720px\"></figure><p>You can try going back then changing the value of the name. The name in the <code class=\"language-text\">NameScreen</code> will change accordingly.</p><h2 id=\"configure-the-header\">Configure the Header</h2><h3 id=\"change-the-title\">Change the title</h3><p>Sometimes, you want the title of a route to be different than the name of the route, or you want the title to be dynamic based on a parameter passed or some other logic.</p><p>In this section, you'll add a new input in <code class=\"language-text\">HomeScreen</code> that will let you to enter a title, then on clicking the navigate button you'll be navigated to a new screen <code class=\"language-text\">TitleScreen</code>, whose title will change based on the title entered in the input in HomeScreen.</p><p>Start by adding a new state variable in <code class=\"language-text\">HomeScreen.js</code> to store the title:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">const</span> <span class=\"token punctuation\">[</span>title<span class=\"token punctuation\">,</span> setTitle<span class=\"token punctuation\">]</span> <span class=\"token operator\">=</span> <span class=\"token function\">useState</span><span class=\"token punctuation\">(</span><span class=\"token string\">''</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div><p>Then, add a new card below the previous cards:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token operator\">&#x3C;</span>Card style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>styles<span class=\"token punctuation\">.</span>card<span class=\"token punctuation\">}</span><span class=\"token operator\">></span>\n        <span class=\"token operator\">&#x3C;</span>Card<span class=\"token punctuation\">.</span>Title title<span class=\"token operator\">=</span><span class=\"token string\">\"Navigate to Route with Title\"</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n        <span class=\"token operator\">&#x3C;</span>Card<span class=\"token punctuation\">.</span>Content<span class=\"token operator\">></span>\n          <span class=\"token operator\">&#x3C;</span>TextInput mode<span class=\"token operator\">=</span><span class=\"token string\">\"outlined\"</span> label<span class=\"token operator\">=</span><span class=\"token string\">\"Title\"</span> value<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>title<span class=\"token punctuation\">}</span> onChangeText<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">text</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token function\">setTitle</span><span class=\"token punctuation\">(</span>text<span class=\"token punctuation\">)</span><span class=\"token punctuation\">}</span> style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>styles<span class=\"token punctuation\">.</span>textInput<span class=\"token punctuation\">}</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n          <span class=\"token operator\">&#x3C;</span>Button mode<span class=\"token operator\">=</span><span class=\"token string\">\"contained\"</span> disabled<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>title<span class=\"token punctuation\">.</span>length <span class=\"token operator\">===</span> <span class=\"token number\">0</span><span class=\"token punctuation\">}</span> onPress<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> navigation<span class=\"token punctuation\">.</span><span class=\"token function\">navigate</span><span class=\"token punctuation\">(</span><span class=\"token string\">'Title'</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">{</span> title <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">}</span><span class=\"token operator\">></span>\n            Navigate\n          <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Button<span class=\"token operator\">></span>\n        <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Card<span class=\"token punctuation\">.</span>Content<span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Card<span class=\"token operator\">></span></code></pre></div><p>This is pretty much the same as the card we added in the previous section. The only difference is that it uses the <code class=\"language-text\">title</code> state variable, and the listener for <code class=\"language-text\">onPress</code> for the button navigates to the route \"Title\", passing the <code class=\"language-text\">title</code> as a parameter.</p><p>Next, create the file <code class=\"language-text\">screens/Title.js</code> with the following content:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">import</span> React <span class=\"token keyword\">from</span> <span class=\"token string\">'react'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> StyleSheet<span class=\"token punctuation\">,</span> View <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> Card <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native-paper'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> DefaultTheme <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native-paper'</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">function</span> <span class=\"token function\">TitleScreen</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token keyword\">return</span> <span class=\"token punctuation\">(</span>\n    <span class=\"token operator\">&#x3C;</span>View style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>styles<span class=\"token punctuation\">.</span>container<span class=\"token punctuation\">}</span><span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span>Card style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>styles<span class=\"token punctuation\">.</span>card<span class=\"token punctuation\">}</span><span class=\"token operator\">></span>\n        <span class=\"token operator\">&#x3C;</span>Card<span class=\"token punctuation\">.</span>Title title<span class=\"token operator\">=</span><span class=\"token string\">\"This is title screen\"</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Card<span class=\"token operator\">></span>\n    <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>View<span class=\"token operator\">></span>\n  <span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span>\n\n<span class=\"token keyword\">const</span> styles <span class=\"token operator\">=</span> StyleSheet<span class=\"token punctuation\">.</span><span class=\"token function\">create</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\n  <span class=\"token literal-property property\">container</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token literal-property property\">flex</span><span class=\"token operator\">:</span> <span class=\"token number\">1</span><span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">flexDirection</span><span class=\"token operator\">:</span> <span class=\"token string\">'column'</span><span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">backgroundColor</span><span class=\"token operator\">:</span> DefaultTheme<span class=\"token punctuation\">.</span>colors<span class=\"token punctuation\">.</span>background<span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">alignItems</span><span class=\"token operator\">:</span> <span class=\"token string\">'center'</span><span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">paddingTop</span><span class=\"token operator\">:</span> <span class=\"token number\">10</span>\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n  <span class=\"token literal-property property\">card</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token literal-property property\">width</span><span class=\"token operator\">:</span> <span class=\"token string\">'90%'</span>\n  <span class=\"token punctuation\">}</span>\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">export</span> <span class=\"token keyword\">default</span> TitleScreen<span class=\"token punctuation\">;</span></code></pre></div><p>This screen has nothing special. It just shows a card with the title \"This is title screen\". It doesn't even use the title parameter.</p><p>That's because you can change the title of a screen by passing an <code class=\"language-text\">options</code> parameter to <code class=\"language-text\">&#x3C;Stack.Screen></code> when adding the route.</p><p>In <code class=\"language-text\">App.js</code>, add an import for <code class=\"language-text\">TitleScreen</code> below other imports at the beginning of the file:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">import</span> TitleScreen <span class=\"token keyword\">from</span> <span class=\"token string\">'./screens/TitleScreen'</span><span class=\"token punctuation\">;</span></code></pre></div><p>Then, add the new route below previous <code class=\"language-text\">&#x3C;Stack.Screen></code>:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token operator\">&#x3C;</span>Stack<span class=\"token punctuation\">.</span>Screen name<span class=\"token operator\">=</span><span class=\"token string\">\"Title\"</span> component<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>TitleScreen<span class=\"token punctuation\">}</span> options<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">(</span><span class=\"token parameter\"><span class=\"token punctuation\">{</span>route<span class=\"token punctuation\">}</span></span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span><span class=\"token literal-property property\">title</span><span class=\"token operator\">:</span> route<span class=\"token punctuation\">.</span>params<span class=\"token punctuation\">.</span>title<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">}</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span></code></pre></div><p>Every <code class=\"language-text\">Stack.Screen</code> component can take an <code class=\"language-text\">options</code> prop. The <code class=\"language-text\">options</code> prop can be an object like so:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\">options<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">{</span><span class=\"token literal-property property\">title</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Hello\"</span><span class=\"token punctuation\">}</span><span class=\"token punctuation\">}</span></code></pre></div><p>This is enough if your options are static. However, if the value for any of the options is dynamic, like in this example, you can instead pass it a function that returns an object. This function can receive as a parameter <code class=\"language-text\">route</code>, which is similar to the <code class=\"language-text\">route</code> parameter you used in <code class=\"language-text\">NameScreen</code>:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\">options<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">(</span><span class=\"token parameter\"><span class=\"token punctuation\">{</span>route<span class=\"token punctuation\">}</span></span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span><span class=\"token literal-property property\">title</span><span class=\"token operator\">:</span> route<span class=\"token punctuation\">.</span>params<span class=\"token punctuation\">.</span>title<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">}</span></code></pre></div><p>In this function, you return an object that has a <code class=\"language-text\">title</code> property with the value <code class=\"language-text\">route.params.title</code>. So, when the user enters a title in the input and clicks on the Navigate button, the title will be passed to the route, which will change the title of \"Title\" route using the function passed to the <code class=\"language-text\">options</code> prop.</p><p>Let's test it out. Run the app if it's not running already. You should see a new card on the Home screen with a new input:</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/12/IMG_1548.PNG\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"1170\" height=\"2532\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1548.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1548.PNG 1000w, https://backend.shahednasser.com/content/images/2021/12/IMG_1548.PNG 1170w\" sizes=\"(min-width: 720px) 720px\"></figure><p>Try entering any title you want in the input then click on Navigate. You'll see that you'll be navigated to the <code class=\"language-text\">TitleScreen</code>, but the title will be the value you entered in the input.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/12/IMG_1549.PNG\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"1170\" height=\"2532\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1549.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1549.PNG 1000w, https://backend.shahednasser.com/content/images/2021/12/IMG_1549.PNG 1170w\" sizes=\"(min-width: 720px) 720px\"></figure><p>You can try going back then changing the value entered in the input. The title of the screen will change accordingly.</p><h3 id=\"add-header-button\">Add Header Button</h3><p>Another option you can add is header buttons. You can customize what your header shows on the left and right by using the <code class=\"language-text\">headerRight</code> and <code class=\"language-text\">headerLeft</code> properties in the <code class=\"language-text\">options</code> param of <code class=\"language-text\">&#x3C;Stack.Screen></code>.</p><p>In this section, you'll add a button to the right of the header of the Home screen which will show a user an alert when they click on it.</p><p>In <code class=\"language-text\">App.js</code>, add to the \"Home\" route a prop <code class=\"language-text\">option</code>:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token operator\">&#x3C;</span>Stack<span class=\"token punctuation\">.</span>Screen name<span class=\"token operator\">=</span><span class=\"token string\">\"Home\"</span> component<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>HomeScreen<span class=\"token punctuation\">}</span> options<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">{</span>\n            <span class=\"token function-variable function\">headerRight</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">(</span>\n              <span class=\"token operator\">&#x3C;</span>IconButton icon<span class=\"token operator\">=</span><span class=\"token string\">\"alert-outline\"</span> onPress<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token function\">alert</span><span class=\"token punctuation\">(</span><span class=\"token string\">'You\\'re awesome!'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">}</span> color<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>DefaultTheme<span class=\"token punctuation\">.</span>colors<span class=\"token punctuation\">.</span>notification<span class=\"token punctuation\">}</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n            <span class=\"token punctuation\">)</span>\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">}</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span></code></pre></div><p>In the <code class=\"language-text\">options</code> prop, you pass an object with the property <code class=\"language-text\">headerRight</code>. The <code class=\"language-text\">headerRight</code> property can be a component that you can render elements inside. You render an <a href=\"https://callstack.github.io/react-native-paper/icon-button.html\">IconButton</a> component, which is a button that only has an icon without text. In the <code class=\"language-text\">onPress</code> event listener, you show an alert to the user.</p><p>That's all. Run the app if it isn't running already. You'll see a new icon at the top right of the header in Home Screen.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/12/IMG_1550.PNG\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"1170\" height=\"2532\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1550.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1550.PNG 1000w, https://backend.shahednasser.com/content/images/2021/12/IMG_1550.PNG 1170w\" sizes=\"(min-width: 720px) 720px\"></figure><p>Click on it and you'll see an alert.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/12/IMG_1551.PNG\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"1170\" height=\"2532\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1551.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1551.PNG 1000w, https://backend.shahednasser.com/content/images/2021/12/IMG_1551.PNG 1170w\" sizes=\"(min-width: 720px) 720px\"></figure><h2 id=\"navigation-events\">Navigation Events</h2><p>In React Navigation, you can subscribe to two events: <code class=\"language-text\">focus</code> and <code class=\"language-text\">blur</code>. The <code class=\"language-text\">focus</code> event will occur every time the screen is opened and is currently the main screen. The <code class=\"language-text\">blur</code> event will occur whenever a screen was in focus but navigation occurs that makes the screen not the current main screen. Simply put, the <code class=\"language-text\">focus</code> event is when the screen is visible to the user, and the <code class=\"language-text\">blur</code> event occurs when a screen was visible to a user but isn't anymore. </p><p>In this section, you'll add a counter that will count how many times you navigated to other screens from the home screen. So, this counter will increment in the <code class=\"language-text\">blur</code> event.</p><p>To subscribe to events, in a <code class=\"language-text\">useEffect</code> callback inside a component, you can use <code class=\"language-text\">navigation.addListener</code> passing it the name of the event as a first parameter, and the event handler as a second parameter. The <code class=\"language-text\">addListener</code> method returns an unsubscribe function which you should return in the <code class=\"language-text\">useEffect</code> callback.</p><p>In <code class=\"language-text\">HomeScreen.js</code>, add an import for <code class=\"language-text\">useEffect</code> at the beginning of the file:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">import</span> React<span class=\"token punctuation\">,</span> <span class=\"token punctuation\">{</span> useEffect<span class=\"token punctuation\">,</span> useState <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react'</span><span class=\"token punctuation\">;</span></code></pre></div><p>Then, add a new state variable <code class=\"language-text\">counter</code> inside the <code class=\"language-text\">HomeScreen</code> component:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">const</span> <span class=\"token punctuation\">[</span>counter<span class=\"token punctuation\">,</span> setCounter<span class=\"token punctuation\">]</span> <span class=\"token operator\">=</span> <span class=\"token function\">useState</span><span class=\"token punctuation\">(</span><span class=\"token number\">0</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div><p>After that add the <code class=\"language-text\">useEffect</code> callback that will register the event handle for the <code class=\"language-text\">blur</code> event:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token function\">useEffect</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\n    <span class=\"token keyword\">return</span> navigation<span class=\"token punctuation\">.</span><span class=\"token function\">addListener</span><span class=\"token punctuation\">(</span><span class=\"token string\">'blur'</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\n      <span class=\"token function\">setCounter</span><span class=\"token punctuation\">(</span>counter <span class=\"token operator\">+</span> <span class=\"token number\">1</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div><p>As you can see, you use <code class=\"language-text\">navigation.addListener</code> to add an event listener to the <code class=\"language-text\">blur</code> event. The function passed as a second parameter is the handler of the event. It will be executed whenever the screen is out of focus (not the screen visible to the user). Inside the event handler, you increment the counter by 1.</p><p>Finally, you'll show the counter at the top of the screen. In <code class=\"language-text\">ScrollView</code>, add a new card before the previously added cards:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token operator\">&#x3C;</span>Card style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>styles<span class=\"token punctuation\">.</span>card<span class=\"token punctuation\">}</span><span class=\"token operator\">></span>\n\t<span class=\"token operator\">&#x3C;</span>Card<span class=\"token punctuation\">.</span>Title title<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token string\">Navigation Count: </span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${</span>counter<span class=\"token interpolation-punctuation punctuation\">}</span></span><span class=\"token template-punctuation string\">`</span></span><span class=\"token punctuation\">}</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n<span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Card<span class=\"token operator\">></span></code></pre></div><p>Let's test it out. Run the app if it's not already running. You should see a card with a count of navigation at the top of the screen.</p><h2 id=\"go-back\">Go Back</h2><p>The last thing you'll learn in this tutorial is how to go back to the previous screen. As you've seen throughout the tutorial, when you navigate to a screen you'll see a back button in the header which you can use to go back to the previous screen.</p><p>Although this is sufficient in most cases, sometimes you want to go back to the previous screen programmatically. You'll create in this section a new screen <code class=\"language-text\">BackScreen</code> which you can go to from the <code class=\"language-text\">HomeScreen</code>. This screen will have a back button in its content and when you click on it you can go back to the previous screen, which is the <code class=\"language-text\">HomeScreen</code>.</p><p>Create the file <code class=\"language-text\">screens/BackScreen.js</code> with the following content:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">import</span> React <span class=\"token keyword\">from</span> <span class=\"token string\">'react'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> StyleSheet<span class=\"token punctuation\">,</span> View <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> Button<span class=\"token punctuation\">,</span> Card <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native-paper'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> DefaultTheme <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native-paper'</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">function</span> <span class=\"token function\">BackScreen</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\"><span class=\"token punctuation\">{</span> navigation <span class=\"token punctuation\">}</span></span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token keyword\">return</span> <span class=\"token punctuation\">(</span>\n    <span class=\"token operator\">&#x3C;</span>View style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>styles<span class=\"token punctuation\">.</span>container<span class=\"token punctuation\">}</span><span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span>Card style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>styles<span class=\"token punctuation\">.</span>card<span class=\"token punctuation\">}</span><span class=\"token operator\">></span>\n        <span class=\"token operator\">&#x3C;</span>Card<span class=\"token punctuation\">.</span>Title title<span class=\"token operator\">=</span><span class=\"token string\">\"This is Back Screen\"</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n        <span class=\"token operator\">&#x3C;</span>Card<span class=\"token punctuation\">.</span>Content<span class=\"token operator\">></span>\n          <span class=\"token operator\">&#x3C;</span>Button mode<span class=\"token operator\">=</span><span class=\"token string\">\"contained\"</span> onPress<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> navigation<span class=\"token punctuation\">.</span><span class=\"token function\">goBack</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">}</span><span class=\"token operator\">></span>\n            Go Back\n          <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Button<span class=\"token operator\">></span>\n        <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Card<span class=\"token punctuation\">.</span>Content<span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Card<span class=\"token operator\">></span>\n    <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>View<span class=\"token operator\">></span>\n  <span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span>\n\n<span class=\"token keyword\">const</span> styles <span class=\"token operator\">=</span> StyleSheet<span class=\"token punctuation\">.</span><span class=\"token function\">create</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\n  <span class=\"token literal-property property\">container</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token literal-property property\">flex</span><span class=\"token operator\">:</span> <span class=\"token number\">1</span><span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">flexDirection</span><span class=\"token operator\">:</span> <span class=\"token string\">'column'</span><span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">backgroundColor</span><span class=\"token operator\">:</span> DefaultTheme<span class=\"token punctuation\">.</span>colors<span class=\"token punctuation\">.</span>background<span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">alignItems</span><span class=\"token operator\">:</span> <span class=\"token string\">'center'</span><span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">paddingTop</span><span class=\"token operator\">:</span> <span class=\"token number\">10</span>\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n  <span class=\"token literal-property property\">card</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token literal-property property\">width</span><span class=\"token operator\">:</span> <span class=\"token string\">'90%'</span>\n  <span class=\"token punctuation\">}</span>\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">export</span> <span class=\"token keyword\">default</span> BackScreen<span class=\"token punctuation\">;</span></code></pre></div><p>This screen is pretty much the same as other screens. The things you should note is that, first, the screen has uses the <code class=\"language-text\">navigation</code> prop that is passed to components inside the navigation stack. Second, the screen has a button inside a card which, on press, will use the <code class=\"language-text\">navigation</code> prop to go back using the <code class=\"language-text\">goBack</code> method:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token operator\">&#x3C;</span>Button mode<span class=\"token operator\">=</span><span class=\"token string\">\"contained\"</span> onPress<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> navigation<span class=\"token punctuation\">.</span><span class=\"token function\">goBack</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">}</span><span class=\"token operator\">></span></code></pre></div><p>Now, go to the <code class=\"language-text\">HomeScreen</code> and add a new card at the end of the ScrollView:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token operator\">&#x3C;</span>Card style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>styles<span class=\"token punctuation\">.</span>card<span class=\"token punctuation\">}</span><span class=\"token operator\">></span>\n    <span class=\"token operator\">&#x3C;</span>Card<span class=\"token punctuation\">.</span>Title title<span class=\"token operator\">=</span><span class=\"token string\">\"Navigate to 'Back' Screen\"</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n    <span class=\"token operator\">&#x3C;</span>Card<span class=\"token punctuation\">.</span>Content<span class=\"token operator\">></span>\n        <span class=\"token operator\">&#x3C;</span>Button mode<span class=\"token operator\">=</span><span class=\"token string\">\"contained\"</span> onPress<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> navigation<span class=\"token punctuation\">.</span><span class=\"token function\">navigate</span><span class=\"token punctuation\">(</span><span class=\"token string\">'Back'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">}</span><span class=\"token operator\">></span>\n            Navigate\n    \t<span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Button<span class=\"token operator\">></span>\n    <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Card<span class=\"token punctuation\">.</span>Content<span class=\"token operator\">></span>\n<span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Card<span class=\"token operator\">></span></code></pre></div><p>This card just shows a button to navigate to the route \"Back\". Let's add that route now.</p><p>In <code class=\"language-text\">App.js</code> add a new <code class=\"language-text\">&#x3C;Stack.Screen></code> component below the previously added ones:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token operator\">&#x3C;</span>Stack<span class=\"token punctuation\">.</span>Screen name<span class=\"token operator\">=</span><span class=\"token string\">\"Back\"</span> component<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>BackScreen<span class=\"token punctuation\">}</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span></code></pre></div><p>It's ready now. Run the app if it isn't already running. You'll see a new card at the end of the list.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/12/IMG_1554.PNG\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"1170\" height=\"2532\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1554.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1554.PNG 1000w, https://backend.shahednasser.com/content/images/2021/12/IMG_1554.PNG 1170w\" sizes=\"(min-width: 720px) 720px\"></figure><p>Click on \"Navigate\" on the last card. You'll be navigated to the <code class=\"language-text\">BackScreen</code>.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/12/IMG_1555.PNG\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"1170\" height=\"2532\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1555.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1555.PNG 1000w, https://backend.shahednasser.com/content/images/2021/12/IMG_1555.PNG 1170w\" sizes=\"(min-width: 720px) 720px\"></figure><p>Click on the \"Go Back\" button in the card. You'll be taken back to the <code class=\"language-text\">HomeScreen</code>.</p><h2 id=\"conclusion\">Conclusion</h2><p>In this tutorial, you learned how to use React Navigation to navigate between screens, pass a parameter from one screen to another, configure the header of a screen, add navigation event listeners, and go back programmatically to the previous screen.</p><p>Although this covers most use cases for using React Navigation, be sure to check out <a href=\"https://reactnavigation.org/docs/getting-started\">their documentation</a> for more details on how to use it. </p>","htmlAst":{"type":"root","children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"https://reactnative.dev"},"children":[{"type":"text","value":"React Native"}]},{"type":"text","value":" is one of the most popular cross-platform app development frameworks. Using JavaScript, you can develop native apps for both Android and iOS."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"One important part of creating apps is being able to navigate between screens. In this tutorial, you'll learn how to use "},{"type":"element","tagName":"a","properties":{"href":"https://reactnavigation.org"},"children":[{"type":"text","value":"React Navigation"}]},{"type":"text","value":" in your app to add navigation. This will include basic navigation from one screen to another, going back to the previous screen, passing parameters, listening to events, and more."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This tutorial will not explain the basics of creating a React Native app. If you're interested in learning about that, you can check out my other tutorial "},{"type":"element","tagName":"a","properties":{"href":"https://blog.shahednasser.com/react-native-tutorial-create-your-first-app"},"children":[{"type":"text","value":"React Native Tutorial: Create Your First App"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can find the code for this tutorial on "},{"type":"element","tagName":"a","properties":{"href":"https://github.com/shahednasser/react-navigation-tutorial"},"children":[{"type":"text","value":"this GitHub repository"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"h2","properties":{"id":"prerequisites"},"children":[{"type":"text","value":"Prerequisites "}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Make sure you have both "},{"type":"element","tagName":"a","properties":{"href":"https://nodejs.org/en/"},"children":[{"type":"text","value":"Node.js"}]},{"type":"text","value":" and NPM installed on your machine. You can check if they're installed with the following command:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"node"}]},{"type":"text","value":" -v\n"},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" -v"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If they're not installed, you can "},{"type":"element","tagName":"a","properties":{"href":"https://nodejs.org/en/"},"children":[{"type":"text","value":"install Node.js"}]},{"type":"text","value":" and NPM will be installed automatically with it."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":" After that, make sure you install "},{"type":"element","tagName":"a","properties":{"href":"https://expo.dev"},"children":[{"type":"text","value":"Expo"}]},{"type":"text","value":"'s CLI if you don't have it installed:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" -g expo-cli"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If you're not familiar with what Expo is, Expo provides a set of tools built around React. Most importantly, it allows you to write and build your React Native app in minutes."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You should also install "},{"type":"element","tagName":"a","properties":{"href":"https://expo.dev/client"},"children":[{"type":"text","value":"Expo Go"}]},{"type":"text","value":" on your device to be able to test the app as we go through the tutorial."}]},{"type":"element","tagName":"h2","properties":{"id":"project-setup"},"children":[{"type":"text","value":"Project Setup"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Start by creating a new React Native project using Expo's CLI:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"expo init react-navigation-tutorial —npm"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You'll be then prompted to choose the type of app, choose \"blank\"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"After that the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"init"}]},{"type":"text","value":" command will install the dependencies you need for your React Native project."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Once it's done, change to the directory of the project:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","builtin","class-name"]},"children":[{"type":"text","value":"cd"}]},{"type":"text","value":" react-navigation-tutorial"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Now, you'll install the dependencies required to use React Navigation. First, install the building blocks libraries using Expo's CLI with the following command:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"expo "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" react-native-screens react-native-safe-area-context"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Second, install the native stack navigator library:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" @react-navigation/native-stack"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Now, you have all the libraries required to start using React Navigation."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Finally, install "},{"type":"element","tagName":"a","properties":{"href":"https://callstack.github.io/react-native-paper/index.html"},"children":[{"type":"text","value":"React Native Paper"}]},{"type":"text","value":" to have beautifully-styled components in your app:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" react-native-paper"}]}]}]},{"type":"element","tagName":"h2","properties":{"id":"set-up-react-navigation"},"children":[{"type":"text","value":"Set Up React Navigation"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Before you can start adding routes to your app, you need to create a Stack Navigator. This stack navigator will be used to create screens and navigate between them."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"App.js"}]},{"type":"text","value":", change the content to the following:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" React "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" NavigationContainer "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'@react-navigation/native'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" createNativeStackNavigator "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'@react-navigation/native-stack'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" Provider "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"as"}]},{"type":"text","value":" PaperProvider "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native-paper'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" HomeScreen "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'./screens/HomeScreen'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" Stack "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"createNativeStackNavigator"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"export"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"default"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"App"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"PaperProvider"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"NavigationContainer"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Stack"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Navigator"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Stack"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Screen name"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Home\""}]},{"type":"text","value":" component"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"HomeScreen"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Stack"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Navigator"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"NavigationContainer"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"PaperProvider"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Notice that in the returned value of "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"App"}]},{"type":"text","value":", you first have "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"<PaperProvider>"}]},{"type":"text","value":" at the top of the elements. This is just used to make sure all screens share the same theme."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Next, you have the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"<NavigationContainer>"}]},{"type":"text","value":". This component manages the navigation tree and contains the navigation state. So, it should wrap Stack navigators."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Inside "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"<NavigationContainer>"}]},{"type":"text","value":" you have "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"<Stack.Navigator>"}]},{"type":"text","value":". "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Stack"}]},{"type":"text","value":" is created using "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"createNativeStackNavigator"}]},{"type":"text","value":". This function returns an object containing 2 properties: "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Screen"}]},{"type":"text","value":" and "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Navigator"}]},{"type":"text","value":". The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Navigator"}]},{"type":"text","value":" property is a React element and it should be used to wrap the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Screen"}]},{"type":"text","value":" elements to manage routing configurations."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"So, inside "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"<Stack.Navigator>"}]},{"type":"text","value":" you'll have one or more "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"<Stack.Screen>"}]},{"type":"text","value":" components. For each route, you'll have a "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"<Stack.Screen>"}]},{"type":"text","value":" component. Now, you just have one component that points to the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Home"}]},{"type":"text","value":" route."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Notice that a "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Screen"}]},{"type":"text","value":" component takes the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"name"}]},{"type":"text","value":" prop, which is the name of the route and will be referenced later on when navigating to this route, and the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"component"}]},{"type":"text","value":" property which is the component to render for this route."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"As you can see, you're passing "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"HomeScreen"}]},{"type":"text","value":" component to the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Home"}]},{"type":"text","value":" route, so you need to create it now."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Create the directory "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"screens"}]},{"type":"text","value":", and inside that directory create a new file "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"HomeScreen.js"}]},{"type":"text","value":" with the following content:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" React "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" ScrollView"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" StyleSheet "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" Button"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" Card "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native-paper'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" DefaultTheme "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native-paper'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"HomeScreen"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"ScrollView style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"styles"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"scrollView"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Card style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"styles"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Title title"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Home Screen\""}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"ScrollView"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" styles "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" StyleSheet"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"create"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"scrollView"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"backgroundColor"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" DefaultTheme"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"colors"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"background"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"paddingTop"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"10"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"card"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"width"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'90%'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"marginLeft"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'auto'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"marginRight"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'auto'"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"export"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"default"}]},{"type":"text","value":" HomeScreen"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This will create a basic home screen with a "},{"type":"element","tagName":"a","properties":{"href":"https://reactnative.dev/docs/scrollview"},"children":[{"type":"text","value":"ScrollView"}]},{"type":"text","value":" component containing a "},{"type":"element","tagName":"a","properties":{"href":"https://callstack.github.io/react-native-paper/card.html"},"children":[{"type":"text","value":"Card"}]},{"type":"text","value":" component with the title \"Home Screen\"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You just created your first route with React Navigation! Let's test it out."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In your terminal run to start your app:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" start"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Then, you'll be able to run the app on Expo Go on your phone by scanning the QR code on the Expo Go app on Android or on the Camera app on iOS."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Once the app run, you'll see the Home screen that you created as it's the default and only route."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2021/12/IMG_1545.PNG","className":["kg-image"],"alt":"","loading":"lazy","width":1170,"height":2532,"srcSet":["https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1545.PNG 600w","https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1545.PNG 1000w","https://backend.shahednasser.com/content/images/2021/12/IMG_1545.PNG 1170w"],"sizes":"(min-width: 720px) 720px"},"children":[]}]},{"type":"element","tagName":"h2","properties":{"id":"navigate-to-another-screen"},"children":[{"type":"text","value":"Navigate to Another Screen"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In this section, you'll learn how to navigate from one screen to another."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Screens that are inside the Stack Navigation, like HomeScreen in this app, receive a "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"navigation"}]},{"type":"text","value":" prop. This prop allows us to navigate to other screens in the app."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's first create the screen you'll navigate to. Create the file "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"screens/BookScreen.js"}]},{"type":"text","value":" with the following content:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" React "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" StyleSheet"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" View "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" Card "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native-paper'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" DefaultTheme "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native-paper'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"BookScreen"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"View style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"styles"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"container"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Card style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"styles"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Title title"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"This is Books Screen\""}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"View"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" styles "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" StyleSheet"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"create"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"container"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"flex"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"1"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"flexDirection"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'column'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"backgroundColor"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" DefaultTheme"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"colors"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"background"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"alignItems"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'center'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"paddingTop"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"10"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"card"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"width"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'90%'"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"export"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"default"}]},{"type":"text","value":" BookScreen"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This screen is similar to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"HomeScreen"}]},{"type":"text","value":". It just shows a card with the title \"This is Books Screen\"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Next, add the new route in "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"App.js"}]},{"type":"text","value":" for "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"BookScreen"}]},{"type":"text","value":" below the \"Home\" route:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Stack"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Screen name"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Book\""}]},{"type":"text","value":" component"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"BookScreen"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Don't forget to import "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"BookScreen"}]},{"type":"text","value":" below the imports at the beginning of "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"App.js"}]},{"type":"text","value":":"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" BookScreen "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'./screens/BookScreen'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Now, you can navigate to the \"Book\" route inside this stack navigation. To see how it works, you'll add a button in "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"HomeScreen"}]},{"type":"text","value":" that when the user clicks will navigate to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"BookScreen"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"HomeScreen"}]},{"type":"text","value":", add the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"navigation"}]},{"type":"text","value":" prop to the function:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"HomeScreen"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" navigation "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Then, change the returned value of the function to the following:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"ScrollView style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"styles"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"scrollView"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Card style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"styles"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Title title"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Navigate to 'Book' Screen\""}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Content"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Button mode"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"contained\""}]},{"type":"text","value":" onPress"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" navigation"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"navigate"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'Book'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n            Navigate\n          "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Button"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Content"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"ScrollView"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You change the title of the card to \"Navigate to 'Book' Screen\". Then, inside the content of the card, you add a "},{"type":"element","tagName":"a","properties":{"href":"https://callstack.github.io/react-native-paper/button.html"},"children":[{"type":"text","value":"Button"}]},{"type":"text","value":" component with "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"onPress"}]},{"type":"text","value":" listener. This listener will be executed when the user presses on the button."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Inside the listener, you use the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"navigation"}]},{"type":"text","value":" prop to navigate to the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Book"}]},{"type":"text","value":" screen using the method "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"navigate"}]},{"type":"text","value":". The method "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"navigate"}]},{"type":"text","value":" takes the name of the route to navigate to."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's test it out. Run the app again if it isn't running. You should see a new button on the Home screen."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2021/12/IMG_1543.PNG","className":["kg-image"],"alt":"","loading":"lazy","width":1170,"height":2532,"srcSet":["https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1543.PNG 600w","https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1543.PNG 1000w","https://backend.shahednasser.com/content/images/2021/12/IMG_1543.PNG 1170w"],"sizes":"(min-width: 720px) 720px"},"children":[]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Try clicking on the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Navigate"}]},{"type":"text","value":" button. You'll be navigated to the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"BookScreen"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2021/12/IMG_1544.PNG","className":["kg-image"],"alt":"","loading":"lazy","width":1170,"height":2532,"srcSet":["https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1544.PNG 600w","https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1544.PNG 1000w","https://backend.shahednasser.com/content/images/2021/12/IMG_1544.PNG 1170w"],"sizes":"(min-width: 720px) 720px"},"children":[]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Notice how the back button in the navigation bar is added automatically when you navigate to another screen. You can use it to go back to the previous screen, which is in this case the Home screen."}]},{"type":"element","tagName":"h2","properties":{"id":"navigate-with-parameters"},"children":[{"type":"text","value":"Navigate with Parameters"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In a lot of cases, you'll need to navigate to another screen and pass it parameters. In this section, you'll create an input that allows the user to enter their name, then when they submit you'll open a new screen called "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NameScreen"}]},{"type":"text","value":" which will show a greeting to the user with the name they entered."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Start by adding a new state variable to hold the value of the input you'll add soon in "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"HomeScreen.js"}]},{"type":"text","value":":"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"text","value":"name"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" setName"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"useState"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"''"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Make sure to add an import for "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"useState"}]},{"type":"text","value":" at the beginning of the file:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" React"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" useState "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Then, add a new Card component below the existing one:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Card style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"styles"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Title title"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Navigate with Parameters\""}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Content"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"TextInput mode"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"outlined\""}]},{"type":"text","value":" label"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Name\""}]},{"type":"text","value":" value"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"name"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" onChangeText"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"text"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setName"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"text"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"styles"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"textInput"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n            "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Button mode"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"contained\""}]},{"type":"text","value":" disabled"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"name"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"length "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"==="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"0"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" onPress"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" navigation"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"navigate"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'Name'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" name "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n                Navigate\n    \t"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Button"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Content"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This new card has a "},{"type":"element","tagName":"a","properties":{"href":"https://callstack.github.io/react-native-paper/text-input.html"},"children":[{"type":"text","value":"TextInput"}]},{"type":"text","value":" with the value "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"name"}]},{"type":"text","value":", and on the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"onChangeText"}]},{"type":"text","value":" event, which occurs when the user makes changes to the text inside the input, you change the value of the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"name"}]},{"type":"text","value":" state variable."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Below the input, you have a button that is disabled when the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"name"}]},{"type":"text","value":" state variable is empty. You also add an "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"onPress"}]},{"type":"text","value":" event listener which navigates the user to the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Name"}]},{"type":"text","value":" route. "}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Notice that you're using the same "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"navigation.navigate"}]},{"type":"text","value":" method that you used before to navigate to the \"Book\" route, however, this time you pass a second parameter to the method. This method accepts as a second parameter an object of parameters you want to pass. Here, you pass the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"name"}]},{"type":"text","value":" variable inside the object."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"One last thing you need to do in the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"HomeScreen"}]},{"type":"text","value":" is change the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"styles"}]},{"type":"text","value":" object to the following:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" styles "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" StyleSheet"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"create"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"scrollView"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"backgroundColor"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" DefaultTheme"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"colors"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"background"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"paddingTop"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"10"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"card"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"width"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'90%'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"marginLeft"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'auto'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"marginRight"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'auto'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"marginBottom"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"10"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"textInput"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"marginBottom"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"10"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This just makes some changes to the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"card"}]},{"type":"text","value":" property and adds a new property "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"textInput"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You'll now create the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NameScreen"}]},{"type":"text","value":" which will be the component for the \"Name\" route you'll add soon. Create "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"screens/NameScreen.js"}]},{"type":"text","value":" with the following content:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" React "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" StyleSheet"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" View "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" Card "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native-paper'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" DefaultTheme "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native-paper'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"NameScreen"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" route "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" name "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" route"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"params"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"View style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"styles"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"container"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Card style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"styles"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Title title"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","template-string"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","template-punctuation","string"]},"children":[{"type":"text","value":"`"}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"Hello, "}]},{"type":"element","tagName":"span","properties":{"className":["token","interpolation"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","interpolation-punctuation","punctuation"]},"children":[{"type":"text","value":"${"}]},{"type":"text","value":"name"},{"type":"element","tagName":"span","properties":{"className":["token","interpolation-punctuation","punctuation"]},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tagName":"span","properties":{"className":["token","template-punctuation","string"]},"children":[{"type":"text","value":"`"}]}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"View"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" styles "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" StyleSheet"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"create"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"container"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"flex"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"1"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"flexDirection"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'column'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"backgroundColor"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" DefaultTheme"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"colors"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"background"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"alignItems"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'center'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"paddingTop"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"10"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"card"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"width"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'90%'"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"export"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"default"}]},{"type":"text","value":" NameScreen"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This screen is essentially the same as "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"BookScreen"}]},{"type":"text","value":", however, notice the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"route"}]},{"type":"text","value":" prop passed to the function."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"As mentioned before, the components inside the navigation stack receive a "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"navigation"}]},{"type":"text","value":" prop to navigate between screens. They also receive a "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"route"}]},{"type":"text","value":" prop which you can use to get the parameters passed to the screen using "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"route.params"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"So, in "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NameScreen"}]},{"type":"text","value":", you retrieve the value entered in the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Name"}]},{"type":"text","value":" input in the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"HomeScreen"}]},{"type":"text","value":", which is passed when navigating to the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NameScreen"}]},{"type":"text","value":" when the button is clicked using "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"route.params"}]},{"type":"text","value":":"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" name "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" route"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"params"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You then show the user a greeting inside a card using the name parameter."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"One last thing left to do is add the \"Name\" route to the navigation stack. Add a new "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"<Stack.Screen>"}]},{"type":"text","value":" below the previous ones in "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"App.js"}]},{"type":"text","value":":"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Stack"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Screen name"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Name\""}]},{"type":"text","value":" component"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"NameScreen"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"And import "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NameScreen"}]},{"type":"text","value":" below other imports at the beginning of the file:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" NameScreen "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'./screens/NameScreen'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's test it out. Run the app if it isn't already running. You'll see that there's a new card on the Home screen with an input and a button."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2021/12/IMG_1546.PNG","className":["kg-image"],"alt":"","loading":"lazy","width":1170,"height":2532,"srcSet":["https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1546.PNG 600w","https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1546.PNG 1000w","https://backend.shahednasser.com/content/images/2021/12/IMG_1546.PNG 1170w"],"sizes":"(min-width: 720px) 720px"},"children":[]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Try entering your name, then click the \"Navigate\" button below the input. You'll be navigated to the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NameScreen"}]},{"type":"text","value":" and you'll see your name."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2021/12/IMG_1547.PNG","className":["kg-image"],"alt":"","loading":"lazy","width":1170,"height":2532,"srcSet":["https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1547.PNG 600w","https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1547.PNG 1000w","https://backend.shahednasser.com/content/images/2021/12/IMG_1547.PNG 1170w"],"sizes":"(min-width: 720px) 720px"},"children":[]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can try going back then changing the value of the name. The name in the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NameScreen"}]},{"type":"text","value":" will change accordingly."}]},{"type":"element","tagName":"h2","properties":{"id":"configure-the-header"},"children":[{"type":"text","value":"Configure the Header"}]},{"type":"element","tagName":"h3","properties":{"id":"change-the-title"},"children":[{"type":"text","value":"Change the title"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Sometimes, you want the title of a route to be different than the name of the route, or you want the title to be dynamic based on a parameter passed or some other logic."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In this section, you'll add a new input in "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"HomeScreen"}]},{"type":"text","value":" that will let you to enter a title, then on clicking the navigate button you'll be navigated to a new screen "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"TitleScreen"}]},{"type":"text","value":", whose title will change based on the title entered in the input in HomeScreen."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Start by adding a new state variable in "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"HomeScreen.js"}]},{"type":"text","value":" to store the title:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"text","value":"title"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" setTitle"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"useState"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"''"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Then, add a new card below the previous cards:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Card style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"styles"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Title title"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Navigate to Route with Title\""}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Content"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"TextInput mode"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"outlined\""}]},{"type":"text","value":" label"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Title\""}]},{"type":"text","value":" value"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"title"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" onChangeText"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"text"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setTitle"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"text"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"styles"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"textInput"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Button mode"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"contained\""}]},{"type":"text","value":" disabled"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"title"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"length "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"==="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"0"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" onPress"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" navigation"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"navigate"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'Title'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" title "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n            Navigate\n          "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Button"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Content"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This is pretty much the same as the card we added in the previous section. The only difference is that it uses the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"title"}]},{"type":"text","value":" state variable, and the listener for "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"onPress"}]},{"type":"text","value":" for the button navigates to the route \"Title\", passing the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"title"}]},{"type":"text","value":" as a parameter."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Next, create the file "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"screens/Title.js"}]},{"type":"text","value":" with the following content:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" React "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" StyleSheet"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" View "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" Card "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native-paper'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" DefaultTheme "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native-paper'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"TitleScreen"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"View style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"styles"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"container"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Card style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"styles"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Title title"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"This is title screen\""}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"View"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" styles "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" StyleSheet"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"create"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"container"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"flex"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"1"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"flexDirection"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'column'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"backgroundColor"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" DefaultTheme"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"colors"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"background"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"alignItems"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'center'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"paddingTop"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"10"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"card"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"width"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'90%'"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"export"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"default"}]},{"type":"text","value":" TitleScreen"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This screen has nothing special. It just shows a card with the title \"This is title screen\". It doesn't even use the title parameter."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"That's because you can change the title of a screen by passing an "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"options"}]},{"type":"text","value":" parameter to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"<Stack.Screen>"}]},{"type":"text","value":" when adding the route."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"App.js"}]},{"type":"text","value":", add an import for "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"TitleScreen"}]},{"type":"text","value":" below other imports at the beginning of the file:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" TitleScreen "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'./screens/TitleScreen'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Then, add the new route below previous "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"<Stack.Screen>"}]},{"type":"text","value":":"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Stack"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Screen name"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Title\""}]},{"type":"text","value":" component"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"TitleScreen"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" options"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"route"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"title"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" route"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"params"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"title"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Every "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Stack.Screen"}]},{"type":"text","value":" component can take an "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"options"}]},{"type":"text","value":" prop. The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"options"}]},{"type":"text","value":" prop can be an object like so:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"text","value":"options"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"title"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Hello\""}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This is enough if your options are static. However, if the value for any of the options is dynamic, like in this example, you can instead pass it a function that returns an object. This function can receive as a parameter "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"route"}]},{"type":"text","value":", which is similar to the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"route"}]},{"type":"text","value":" parameter you used in "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NameScreen"}]},{"type":"text","value":":"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"text","value":"options"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"route"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"title"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" route"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"params"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"title"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In this function, you return an object that has a "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"title"}]},{"type":"text","value":" property with the value "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"route.params.title"}]},{"type":"text","value":". So, when the user enters a title in the input and clicks on the Navigate button, the title will be passed to the route, which will change the title of \"Title\" route using the function passed to the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"options"}]},{"type":"text","value":" prop."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's test it out. Run the app if it's not running already. You should see a new card on the Home screen with a new input:"}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2021/12/IMG_1548.PNG","className":["kg-image"],"alt":"","loading":"lazy","width":1170,"height":2532,"srcSet":["https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1548.PNG 600w","https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1548.PNG 1000w","https://backend.shahednasser.com/content/images/2021/12/IMG_1548.PNG 1170w"],"sizes":"(min-width: 720px) 720px"},"children":[]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Try entering any title you want in the input then click on Navigate. You'll see that you'll be navigated to the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"TitleScreen"}]},{"type":"text","value":", but the title will be the value you entered in the input."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2021/12/IMG_1549.PNG","className":["kg-image"],"alt":"","loading":"lazy","width":1170,"height":2532,"srcSet":["https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1549.PNG 600w","https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1549.PNG 1000w","https://backend.shahednasser.com/content/images/2021/12/IMG_1549.PNG 1170w"],"sizes":"(min-width: 720px) 720px"},"children":[]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can try going back then changing the value entered in the input. The title of the screen will change accordingly."}]},{"type":"element","tagName":"h3","properties":{"id":"add-header-button"},"children":[{"type":"text","value":"Add Header Button"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Another option you can add is header buttons. You can customize what your header shows on the left and right by using the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"headerRight"}]},{"type":"text","value":" and "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"headerLeft"}]},{"type":"text","value":" properties in the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"options"}]},{"type":"text","value":" param of "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"<Stack.Screen>"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In this section, you'll add a button to the right of the header of the Home screen which will show a user an alert when they click on it."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"App.js"}]},{"type":"text","value":", add to the \"Home\" route a prop "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"option"}]},{"type":"text","value":":"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Stack"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Screen name"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Home\""}]},{"type":"text","value":" component"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"HomeScreen"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" options"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n            "},{"type":"element","tagName":"span","properties":{"className":["token","function-variable","function"]},"children":[{"type":"text","value":"headerRight"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n              "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"IconButton icon"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"alert-outline\""}]},{"type":"text","value":" onPress"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"alert"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'You\\'re awesome!'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" color"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"DefaultTheme"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"colors"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"notification"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n            "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"options"}]},{"type":"text","value":" prop, you pass an object with the property "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"headerRight"}]},{"type":"text","value":". The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"headerRight"}]},{"type":"text","value":" property can be a component that you can render elements inside. You render an "},{"type":"element","tagName":"a","properties":{"href":"https://callstack.github.io/react-native-paper/icon-button.html"},"children":[{"type":"text","value":"IconButton"}]},{"type":"text","value":" component, which is a button that only has an icon without text. In the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"onPress"}]},{"type":"text","value":" event listener, you show an alert to the user."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"That's all. Run the app if it isn't running already. You'll see a new icon at the top right of the header in Home Screen."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2021/12/IMG_1550.PNG","className":["kg-image"],"alt":"","loading":"lazy","width":1170,"height":2532,"srcSet":["https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1550.PNG 600w","https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1550.PNG 1000w","https://backend.shahednasser.com/content/images/2021/12/IMG_1550.PNG 1170w"],"sizes":"(min-width: 720px) 720px"},"children":[]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Click on it and you'll see an alert."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2021/12/IMG_1551.PNG","className":["kg-image"],"alt":"","loading":"lazy","width":1170,"height":2532,"srcSet":["https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1551.PNG 600w","https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1551.PNG 1000w","https://backend.shahednasser.com/content/images/2021/12/IMG_1551.PNG 1170w"],"sizes":"(min-width: 720px) 720px"},"children":[]}]},{"type":"element","tagName":"h2","properties":{"id":"navigation-events"},"children":[{"type":"text","value":"Navigation Events"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In React Navigation, you can subscribe to two events: "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"focus"}]},{"type":"text","value":" and "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"blur"}]},{"type":"text","value":". The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"focus"}]},{"type":"text","value":" event will occur every time the screen is opened and is currently the main screen. The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"blur"}]},{"type":"text","value":" event will occur whenever a screen was in focus but navigation occurs that makes the screen not the current main screen. Simply put, the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"focus"}]},{"type":"text","value":" event is when the screen is visible to the user, and the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"blur"}]},{"type":"text","value":" event occurs when a screen was visible to a user but isn't anymore. "}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In this section, you'll add a counter that will count how many times you navigated to other screens from the home screen. So, this counter will increment in the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"blur"}]},{"type":"text","value":" event."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To subscribe to events, in a "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"useEffect"}]},{"type":"text","value":" callback inside a component, you can use "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"navigation.addListener"}]},{"type":"text","value":" passing it the name of the event as a first parameter, and the event handler as a second parameter. The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"addListener"}]},{"type":"text","value":" method returns an unsubscribe function which you should return in the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"useEffect"}]},{"type":"text","value":" callback."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"HomeScreen.js"}]},{"type":"text","value":", add an import for "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"useEffect"}]},{"type":"text","value":" at the beginning of the file:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" React"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" useEffect"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" useState "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Then, add a new state variable "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"counter"}]},{"type":"text","value":" inside the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"HomeScreen"}]},{"type":"text","value":" component:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"text","value":"counter"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" setCounter"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"useState"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"0"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"After that add the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"useEffect"}]},{"type":"text","value":" callback that will register the event handle for the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"blur"}]},{"type":"text","value":" event:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"useEffect"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"text","value":" navigation"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"addListener"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'blur'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setCounter"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"counter "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"+"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"1"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"As you can see, you use "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"navigation.addListener"}]},{"type":"text","value":" to add an event listener to the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"blur"}]},{"type":"text","value":" event. The function passed as a second parameter is the handler of the event. It will be executed whenever the screen is out of focus (not the screen visible to the user). Inside the event handler, you increment the counter by 1."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Finally, you'll show the counter at the top of the screen. In "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"ScrollView"}]},{"type":"text","value":", add a new card before the previously added cards:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Card style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"styles"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n\t"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Title title"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","template-string"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","template-punctuation","string"]},"children":[{"type":"text","value":"`"}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"Navigation Count: "}]},{"type":"element","tagName":"span","properties":{"className":["token","interpolation"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","interpolation-punctuation","punctuation"]},"children":[{"type":"text","value":"${"}]},{"type":"text","value":"counter"},{"type":"element","tagName":"span","properties":{"className":["token","interpolation-punctuation","punctuation"]},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tagName":"span","properties":{"className":["token","template-punctuation","string"]},"children":[{"type":"text","value":"`"}]}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's test it out. Run the app if it's not already running. You should see a card with a count of navigation at the top of the screen."}]},{"type":"element","tagName":"h2","properties":{"id":"go-back"},"children":[{"type":"text","value":"Go Back"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The last thing you'll learn in this tutorial is how to go back to the previous screen. As you've seen throughout the tutorial, when you navigate to a screen you'll see a back button in the header which you can use to go back to the previous screen."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Although this is sufficient in most cases, sometimes you want to go back to the previous screen programmatically. You'll create in this section a new screen "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"BackScreen"}]},{"type":"text","value":" which you can go to from the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"HomeScreen"}]},{"type":"text","value":". This screen will have a back button in its content and when you click on it you can go back to the previous screen, which is the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"HomeScreen"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Create the file "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"screens/BackScreen.js"}]},{"type":"text","value":" with the following content:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" React "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" StyleSheet"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" View "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" Button"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" Card "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native-paper'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" DefaultTheme "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native-paper'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"BackScreen"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" navigation "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"View style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"styles"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"container"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Card style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"styles"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Title title"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"This is Back Screen\""}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Content"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Button mode"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"contained\""}]},{"type":"text","value":" onPress"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" navigation"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"goBack"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n            Go Back\n          "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Button"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Content"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"View"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" styles "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" StyleSheet"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"create"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"container"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"flex"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"1"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"flexDirection"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'column'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"backgroundColor"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" DefaultTheme"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"colors"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"background"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"alignItems"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'center'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"paddingTop"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"10"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"card"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"width"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'90%'"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"export"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"default"}]},{"type":"text","value":" BackScreen"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This screen is pretty much the same as other screens. The things you should note is that, first, the screen has uses the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"navigation"}]},{"type":"text","value":" prop that is passed to components inside the navigation stack. Second, the screen has a button inside a card which, on press, will use the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"navigation"}]},{"type":"text","value":" prop to go back using the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"goBack"}]},{"type":"text","value":" method:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Button mode"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"contained\""}]},{"type":"text","value":" onPress"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" navigation"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"goBack"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Now, go to the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"HomeScreen"}]},{"type":"text","value":" and add a new card at the end of the ScrollView:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Card style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"styles"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Title title"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Navigate to 'Back' Screen\""}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Content"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Button mode"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"contained\""}]},{"type":"text","value":" onPress"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" navigation"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"navigate"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'Back'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n            Navigate\n    \t"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Button"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Content"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This card just shows a button to navigate to the route \"Back\". Let's add that route now."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"App.js"}]},{"type":"text","value":" add a new "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"<Stack.Screen>"}]},{"type":"text","value":" component below the previously added ones:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Stack"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Screen name"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Back\""}]},{"type":"text","value":" component"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"BackScreen"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"It's ready now. Run the app if it isn't already running. You'll see a new card at the end of the list."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2021/12/IMG_1554.PNG","className":["kg-image"],"alt":"","loading":"lazy","width":1170,"height":2532,"srcSet":["https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1554.PNG 600w","https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1554.PNG 1000w","https://backend.shahednasser.com/content/images/2021/12/IMG_1554.PNG 1170w"],"sizes":"(min-width: 720px) 720px"},"children":[]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Click on \"Navigate\" on the last card. You'll be navigated to the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"BackScreen"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2021/12/IMG_1555.PNG","className":["kg-image"],"alt":"","loading":"lazy","width":1170,"height":2532,"srcSet":["https://backend.shahednasser.com/content/images/size/w600/2021/12/IMG_1555.PNG 600w","https://backend.shahednasser.com/content/images/size/w1000/2021/12/IMG_1555.PNG 1000w","https://backend.shahednasser.com/content/images/2021/12/IMG_1555.PNG 1170w"],"sizes":"(min-width: 720px) 720px"},"children":[]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Click on the \"Go Back\" button in the card. You'll be taken back to the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"HomeScreen"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"h2","properties":{"id":"conclusion"},"children":[{"type":"text","value":"Conclusion"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In this tutorial, you learned how to use React Navigation to navigate between screens, pass a parameter from one screen to another, configure the header of a screen, add navigation event listeners, and go back programmatically to the previous screen."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Although this covers most use cases for using React Navigation, be sure to check out "},{"type":"element","tagName":"a","properties":{"href":"https://reactnavigation.org/docs/getting-started"},"children":[{"type":"text","value":"their documentation"}]},{"type":"text","value":" for more details on how to use it. "}]}],"data":{"quirksMode":false}},"tableOfContents":[{"id":"prerequisites","heading":"Prerequisites "},{"id":"project-setup","heading":"Project Setup"},{"id":"set-up-react-navigation","heading":"Set Up React Navigation"},{"id":"navigate-to-another-screen","heading":"Navigate to Another Screen"},{"id":"navigate-with-parameters","heading":"Navigate with Parameters"},{"id":"configure-the-header","heading":"Configure the Header","items":[{"id":"change-the-title","heading":"Change the title"},{"id":"add-header-button","heading":"Add Header Button"}]},{"id":"navigation-events","heading":"Navigation Events"},{"id":"go-back","heading":"Go Back"},{"id":"conclusion","heading":"Conclusion"}]},"featureImageSharp":{"base":"nathan-da-silva-FO7kUmBYVi0-unsplash-2.jpg","publicURL":"/static/de081a39f1737345436f7c509de3f888/nathan-da-silva-FO7kUmBYVi0-unsplash-2.jpg","imageMeta":{"width":1920,"height":1920},"childImageSharp":{"fluid":{"base64":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAUABQDASIAAhEBAxEB/8QAGAABAQEBAQAAAAAAAAAAAAAAAAQDAQX/xAAWAQEBAQAAAAAAAAAAAAAAAAABAAL/2gAMAwEAAhADEAAAAa/MqiqloGXpjeoH/8QAHBAAAwABBQAAAAAAAAAAAAAAAQIDBAAREhNB/9oACAEBAAEFAsp2SUbGtaYoL3r2pORDkjck8vdf/8QAFREBAQAAAAAAAAAAAAAAAAAAEAL/2gAIAQMBAT8BJP/EABURAQEAAAAAAAAAAAAAAAAAABAC/9oACAECAQE/ASj/xAAdEAACAgIDAQAAAAAAAAAAAAABAgARITEQImFx/9oACAEBAAY/AjjF1ERqqE2IwC7gZgFHpnXI+Sr1z//EABsQAQADAQADAAAAAAAAAAAAAAEAESFBUWGR/9oACAEBAAE/IcQNHtKWxcztQcb63ctHcd3IYFtrA/0rRe4NFRMLa+XYs//aAAwDAQACAAMAAAAQcxD/AP/EABoRAAICAwAAAAAAAAAAAAAAAAABEBEhQVH/2gAIAQMBAT8Q2Z4KquP/xAAZEQACAwEAAAAAAAAAAAAAAAAAARARQYH/2gAIAQIBAT8Qw6O7j//EAB4QAQACAgIDAQAAAAAAAAAAAAEAESExUWFBcZGh/9oACAEBAAE/EMGIlt7DxBWSKotFV36jFK1KVVy4YwKlYoFbCs+JvJCExYLifzwlwUG3QYK/b22/Ytz/2Q==","aspectRatio":1,"src":"/static/de081a39f1737345436f7c509de3f888/ea4ab/nathan-da-silva-FO7kUmBYVi0-unsplash-2.jpg","srcSet":"/static/de081a39f1737345436f7c509de3f888/477ba/nathan-da-silva-FO7kUmBYVi0-unsplash-2.jpg 175w,\n/static/de081a39f1737345436f7c509de3f888/06776/nathan-da-silva-FO7kUmBYVi0-unsplash-2.jpg 350w,\n/static/de081a39f1737345436f7c509de3f888/ea4ab/nathan-da-silva-FO7kUmBYVi0-unsplash-2.jpg 700w,\n/static/de081a39f1737345436f7c509de3f888/3055e/nathan-da-silva-FO7kUmBYVi0-unsplash-2.jpg 1050w,\n/static/de081a39f1737345436f7c509de3f888/eff08/nathan-da-silva-FO7kUmBYVi0-unsplash-2.jpg 1400w,\n/static/de081a39f1737345436f7c509de3f888/74fd5/nathan-da-silva-FO7kUmBYVi0-unsplash-2.jpg 1920w","srcWebp":"/static/de081a39f1737345436f7c509de3f888/89afa/nathan-da-silva-FO7kUmBYVi0-unsplash-2.webp","srcSetWebp":"/static/de081a39f1737345436f7c509de3f888/9fca7/nathan-da-silva-FO7kUmBYVi0-unsplash-2.webp 175w,\n/static/de081a39f1737345436f7c509de3f888/37a4e/nathan-da-silva-FO7kUmBYVi0-unsplash-2.webp 350w,\n/static/de081a39f1737345436f7c509de3f888/89afa/nathan-da-silva-FO7kUmBYVi0-unsplash-2.webp 700w,\n/static/de081a39f1737345436f7c509de3f888/78e7a/nathan-da-silva-FO7kUmBYVi0-unsplash-2.webp 1050w,\n/static/de081a39f1737345436f7c509de3f888/03d34/nathan-da-silva-FO7kUmBYVi0-unsplash-2.webp 1400w,\n/static/de081a39f1737345436f7c509de3f888/6833b/nathan-da-silva-FO7kUmBYVi0-unsplash-2.webp 1920w","sizes":"(max-width: 700px) 100vw, 700px"}}}}},{"node":{"id":"Ghost__Post__614f6edf9d27d705cce79807","title":"React Native Tutorial: Create Your First App","slug":"react-native-tutorial-create-your-first-app","featured":false,"feature_image":"https://backend.shahednasser.com/content/images/2021/09/jonathan-kemper-t6Wmvbw_MdI-unsplash-2-2.jpg","excerpt":"In this tutorial, you'll learn the basics of creating a React Native app with Expo.","custom_excerpt":"In this tutorial, you'll learn the basics of creating a React Native app with Expo.","visibility":"public","created_at_pretty":"25 Sep 2021","published_at_pretty":"27 Sep 2021","updated_at_pretty":"9 Dec 2021","created_at":"2021-09-25T18:47:59.000+00:00","published_at":"2021-09-27T14:22:06.000+00:00","updated_at":"2021-12-09T14:20:36.000+00:00","meta_title":null,"meta_description":null,"og_description":null,"og_image":null,"og_title":null,"twitter_description":null,"twitter_image":null,"twitter_title":null,"authors":[{"slug":"shahed","url":"https://backend.shahednasser.com/author/shahed/","name":"Shahed Nasser","bio":null,"cover_image":null,"profile_image":"https://backend.shahednasser.com/content/images/2022/03/IMG_0591.jpg","location":null,"website":null,"twitter":null,"facebook":null,"meta_title":null,"meta_description":null,"coverImageSharp":null,"profileImageSharp":null}],"primary_author":{"slug":"shahed","url":"https://backend.shahednasser.com/author/shahed/","name":"Shahed Nasser","bio":null,"cover_image":null,"profile_image":"https://backend.shahednasser.com/content/images/2022/03/IMG_0591.jpg","location":null,"website":null,"twitter":null,"facebook":null,"meta_title":null,"meta_description":null,"coverImageSharp":null,"profileImageSharp":{"base":"IMG_0591.jpg","publicURL":"/static/ceb49c3c631485453e71e00d7f84b069/IMG_0591.jpg","imageMeta":{"width":1182,"height":1179},"childImageSharp":{"fluid":{"base64":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAUABQDASIAAhEBAxEB/8QAGAABAQEBAQAAAAAAAAAAAAAAAAMEAQL/xAAWAQEBAQAAAAAAAAAAAAAAAAADBAL/2gAMAwEAAhADEAAAAdXiFM6i0CohUWXoKn//xAAcEAACAgIDAAAAAAAAAAAAAAACAwESBBEhM0H/2gAIAQEAAQUCWySE3WEr7SzbXjAj4iKty+sOQ//EABYRAQEBAAAAAAAAAAAAAAAAAAERIP/aAAgBAwEBPwEhj//EABQRAQAAAAAAAAAAAAAAAAAAACD/2gAIAQIBAT8BH//EAB4QAAIBBAMBAAAAAAAAAAAAAAABIRESMUECECJx/9oACAEBAAY/ApVGWvOjzgtUwLlTZA0sdL4f/8QAHBAAAwACAwEAAAAAAAAAAAAAAAERITFBkbHB/9oACAEBAAE/IahkCy+N2GwZpjQiJHJCspUFY0QrSi+HqiW2rgf/2gAMAwEAAgADAAAAEPw3/wD/xAAYEQEBAAMAAAAAAAAAAAAAAAAAARExQf/aAAgBAwEBPxCtjDqP/8QAFxEBAQEBAAAAAAAAAAAAAAAAAQAxEf/aAAgBAgEBPxBFus6Tt//EAB8QAQEAAgIBBQAAAAAAAAAAAAERACExQWFRcYGR0f/aAAgBAQABPxAuaBPPzkO1wyX7F4wkwXanfZrFQgeqE9JgS14vVOvrERIJomVBKwt2jebAeP0yVa8h1n//2Q==","aspectRatio":1,"src":"/static/ceb49c3c631485453e71e00d7f84b069/31709/IMG_0591.jpg","srcSet":"/static/ceb49c3c631485453e71e00d7f84b069/f340b/IMG_0591.jpg 28w,\n/static/ceb49c3c631485453e71e00d7f84b069/22d64/IMG_0591.jpg 55w,\n/static/ceb49c3c631485453e71e00d7f84b069/31709/IMG_0591.jpg 110w,\n/static/ceb49c3c631485453e71e00d7f84b069/aa249/IMG_0591.jpg 165w,\n/static/ceb49c3c631485453e71e00d7f84b069/0dc33/IMG_0591.jpg 220w,\n/static/ceb49c3c631485453e71e00d7f84b069/d8257/IMG_0591.jpg 1182w","srcWebp":"/static/ceb49c3c631485453e71e00d7f84b069/8678c/IMG_0591.webp","srcSetWebp":"/static/ceb49c3c631485453e71e00d7f84b069/59cda/IMG_0591.webp 28w,\n/static/ceb49c3c631485453e71e00d7f84b069/7da75/IMG_0591.webp 55w,\n/static/ceb49c3c631485453e71e00d7f84b069/8678c/IMG_0591.webp 110w,\n/static/ceb49c3c631485453e71e00d7f84b069/f282e/IMG_0591.webp 165w,\n/static/ceb49c3c631485453e71e00d7f84b069/a7b21/IMG_0591.webp 220w,\n/static/ceb49c3c631485453e71e00d7f84b069/63099/IMG_0591.webp 1182w","sizes":"(max-width: 110px) 100vw, 110px"}}}},"primary_tag":{"slug":"react-native","url":"https://backend.shahednasser.com/tag/react-native/","name":"React Native","visibility":"public","feature_image":null,"description":null,"meta_title":null,"meta_description":null,"featureImageSharp":null},"tags":[{"slug":"react-native","url":"https://backend.shahednasser.com/tag/react-native/","name":"React Native","visibility":"public","feature_image":null,"description":null,"meta_title":null,"meta_description":null,"featureImageSharp":null},{"slug":"beginner","url":"https://backend.shahednasser.com/tag/beginner/","name":"Beginners","visibility":"public","feature_image":"https://backend.shahednasser.com/content/images/2022/01/photo-1521185496955-15097b20c5fe-2.jpeg","description":"Tutorials, articles, and tips to help beginners accelerate their journey in programming.","meta_title":"Beginners","meta_description":"Tutorials, articles, and tips to help beginners accelerate their journey in programming.","featureImageSharp":null}],"plaintext":"React Native [https://reactnative.dev] is one of the most popular frameworks\nthat allow you to create cross-platform apps using JavaScript. Using React\nNative, you'll be able to write one code for the web, iOS, and Android.\n\nIn this tutorial, you'll learn the basics of creating a React Native app with \nExpo [https://expo.dev]. We'll create a to-do list app where we'll learn about\nimplementing navigation in a React Native app and storing data in our app.\n\nYou can find the code for this tutorial in this GitHub Repository\n[https://github.com/shahednasser/react-native-tutorial]. You can also install\nthe app [https://expo.dev/@shahednasser/todolist] using Expo Go. There is more\ninfo on how to install Expo Go below.\n\nPrerequisites\nBefore you start going through the tutorial, you'll need to install Node.js\n[https://nodejs.org/en/] which will install NPM with it.\n\nYou also need to install Expo. Expo provides a set of tools to make your mobile\ndevelopment with React Native easier. \n\nTo install Expo run:\n\nnpm install -g expo-cli\n\nFinally, you'll need to install Expo Go [https://expo.dev/client] on your phone.\nIt's available for both Android\n[https://play.google.com/store/apps/details?id=host.exp.exponent&hl=en&gl=US] \nand iOS [https://apps.apple.com/us/app/expo-go/id982107779].\n\nBy installing Expo Go on your phone, you'll be able to test your app directly on\nyour phone as you make changes. \n\nSetup Project\nTo create a new React Native project, run the following command in your\nterminal:\n\nexpo init todolist\n\nYou'll be asked to choose the kind of project you want to create, choose blank.\n\nAfter you choose blank, the project will be set up and the minimal dependencies\nrequired to create an app with React Native will be installed.\n\nAfter the setup is done, change to the directory of the project:\n\ncd todolist\n\nProject Structure\nLet's take a quick look at the project's structure before we start coding.\n\nWe have the usual package.json files that you find in every NPM project.\n\nThere's app.json. This includes a set of configurations for our app. If you open\nit, you'll find key-value pairs related to the app name, version, icon, splash\nscreen, and more.\n\nApp.js is the entry point of our app. It's where we will start writing our app's\ncode.\n\nThe assets directory includes images like the app icon, splash screen, and more.\n\nUnderstand First Components in React Native\nIf you open App.js, you'll find content similar to this:\n\nimport { StatusBar } from 'expo-status-bar';\nimport React from 'react';\nimport { StyleSheet, Text, View } from 'react-native';\n\nexport default function App() {\n  return (\n    <View style={styles.container}>\n      <Text>Open up App.js to start working on your app!</Text>\n      <StatusBar style=\"auto\" />\n    </View>\n  );\n}\n\nconst styles = StyleSheet.create({\n  container: {\n    flex: 1,\n    backgroundColor: '#fff',\n    alignItems: 'center',\n    justifyContent: 'center',\n  },\n});\n\n\nThis is our first component! As you can see, components like View, Text and\nothers imported from react-native are being used.\n\nYou should know that in React Native when displaying the text you need to do it\ninside a Text component. \n\nReact Native provides a set of components that will be later transformed into\nnative components in iOS or Android.\n\nWe also create stylesheets to add styling to our components using \nStyleSheet.create, where StyleSheet is imported from react-native as well.\n\nThe create method takes an object of properties, which act like class names in\nCSS, and their values are objects of CSS-like properties and their values.\nStyling your components in React Native is almost identical to styling using\nCSS, with a few changes in some behaviors of some CSS properties.\n\nScreens and Navigation\nNow, we'll start adding screens to our app. To add different screens and manage\nnavigation between them, we'll use React Navigation\n[https://reactnavigation.org/].\n\nFor an elaborate tutorial on Navigation, check out my tutorial React Native\nNavigation Tutorial\n[https://blog.shahednasser.com/react-native-navigation-tutorial/].\n\nHome Screen\nCreate the directories src/screens. The screens directory will hold all the\nscreens we will create later on.\n\nThen, create HomeScreen.js inside screens. This will be the first screen that\nthe user will see when they open the app.\n\nAdd the following content inside HomeScreen.js:\n\nimport React from 'react';\nimport { Text, View } from 'react-native';\n\nexport default function HomeScreen () {\n  return (\n    <View>\n      <Text>Welcome Home!</Text>\n    </View>\n  )\n}\n\nThe home screen, at the moment, will just display the text \"Welcome Home!\".\n\nInstall React Navigation\nNext, we'll see how to use multiple screens with React Navigation.\n\nReact Navigation allows us to move between screens backward and forwards, add\nbuttons to the header, and more.\n\nTo install React Navigation, run the following commands:\n\nnpm install @react-navigation/native\nexpo install react-native-screens react-native-safe-area-context\nnpm install @react-navigation/native-stack\n\nOnce these commands are done executing, we'll have all the dependencies required\nto use React Navigation.\n\nHow React Navigation Works\nTo put things simply, React Navigation manages screens, navigation between them,\nand history as a Stack. \n\nThere's a default, initial screen that shows when the app is launched. Then,\nwhen you want to open a new screen, you can push it at the top of the stack or\nreplace the current item in the stack.\n\nThen, when you want to go backward, you pop the current item at the top of the\nstack and show the one below it, which was the previous screen, until you reach\nthe home, initial screen.\n\n If it sounds confusing at the moment, keep going through in the tutorial and\nyou'll start understanding things more.\n\nCreate the Navigation Stack\nChange the content of App.js to the following:\n\nimport 'react-native-gesture-handler';\nimport React from 'react';\nimport { createStackNavigator } from '@react-navigation/stack';\nimport { NavigationContainer } from '@react-navigation/native';\nimport HomeScreen from './src/screens/HomeScreen';\n\nconst Stack = createStackNavigator();\n\nexport default function App() {\n  return (\n    <NavigationContainer>\n      <Stack.Navigator initialRouteName=\"Home\">\n        <Stack.Screen name=\"Home\" component={HomeScreen} />\n      </Stack.Navigator>\n    </NavigationContainer>\n  );\n}\n\n\nLet's go over things bit by bit.\n\nWe first need to import react-native-gesture-handler at the top of the app. This\nallows navigating using gestures. The higher in the app it's placed the better.\n\nNext, we're importing createStackNavigator. This function returns a Stack\nobject, which contains two components Screen and Navigator. \n\nScreen is used to display screen components that we create, define their\noptions, and more. If you look at the example above, we provide a name and \ncomponent props for a screen:\n\n<Stack.Screen name=\"Home\" component={HomeScreen} />\n\nThe name prop can be used to navigate to that screen at any given point later.\nThe component prop will be used to define the screen component to render when\nthe screen is navigated to.\n\nNavigator should contain Screen components as children as it manages the routing\nbetween them. Navigator also receives the initialRouteName prop which determines\nthe screen that should open when the app first launches.\n\nFinally, we use NavigationContainer to wrap the Navigator components, as it\nmanages the navigation tree and state.\n\nSo, in App.js, which will contain the navigation routes for the screens in the\napp as we go forward, we should render the NavigationContainer and inside it \nStack.Navigator which contains one or more Stack.Screen components:\n\n<NavigationContainer>\n    <Stack.Navigator initialRouteName=\"Home\">\n        <Stack.Screen name=\"Home\" component={HomeScreen} />\n    </Stack.Navigator>\n</NavigationContainer>\n\nRun the App\nLet's run the app now. To do that, open the terminal and run the following:\n\nnpm start\n\nThis will start Expo. As mentioned earlier, with Expo you will be able to run\nthe app on your phone, so make sure you've installed Expo Go as detailed in the\nPrerequisites section.\n\nA web page will open that looks something like this:\n\nThere are multiple ways to run the app after this on your device. You can scan\nthe QR code with your phone to open it in Expo Go. Alternatively, you can use\none of the actions on the sidebar of the web page above like send link with\nemail and so on.\n\nOnce you choose the best way to open the app on your phone and it opens, you\nshould see the following screen:\n\nWe've run our first app! We'll start customizing the styles of the header next\nand add more screens to create a Todo List app.\n\nStyle the Header\nWith React Navigation, there are 2 ways to style the header of a screen.\n\nStyle Screen Headers Individually\nThe first way is to style it for each screen. This can be done by passing the \noptions prop to a Screen component like this:\n\n<Stack.Screen \n    name=\"Home\" \n    component={HomeScreen} \n    options={{\n\t\theaderStyle: {\n\t\t\tbackgroundColor: '#228CDB'\n\t\t},\n        headerTintColor: '#fff'\n    }} \n/>\n\nThe options prop is an object of options for the screen. To style the header, we\ncan use the following three properties:\n\n 1. headerStyle: accepts an object of styles to apply to the header. To set the\n    background color of the header, we pass it the backgroundColor prop with the\n    value of the background color of the header.\n 2. headerTintColor: the color of the text or buttons that are in the header.\n 3. headerTitleStyle: accepts an object of font-related styles to make changes\n    to the title in the header. For example, we can change the fontFamily or \n    fontWeight.\n\nUsing this prop, we'll be able to style the header of a screen.\n\nStyle All Screen Headers\nIn general cases, styling each screen separately is tedious and leads to\nrepeated code. Usually, you'd apply the same header style to all screens in the\napp.\n\nIn this case, we can use the screenOptions prop on the Navigator component. This\nprop accepts the same header options as the options prop in the Screen component\nand applies the styling to all screens.\n\nApply Header Styles in Our App\nIn our app, we'll apply the same header style to all the screens in the app. So,\nwe'll use the second way to style a header.\n\nIn App.js, replace this line:\n\n<Stack.Navigator initialRouteName=\"Home\">\n\nWith the following:\n\n<Stack.Navigator\n    screenOptions={{\n\t\t\theaderStyle: {\n\t\t\t\tbackgroundColor: '#228CDB'\n\t\t\t},\n        \theaderTintColor: '#fff'\n    \t}} \n    initialRouteName=\"Home\">\n\nThis will change the background color of the header to #228CDB and the color of\nthe text and buttons in the header to #fff.\n\nIf you save the changes and open the app again, you'll see that the header color\nchanged.\n\nNavigate Screens\nNext, we'll see how to add another screen and navigate to it. We'll also see how\nto add a header button.\n\nAdd New Screen\nWe'll add a new screen, which we'll use later to add a new to-do list item. \n\nCreate src/screens/NewScreen.js with the following content:\n\nimport React from 'react';\nimport { Text, View } from 'react-native';\n\nexport default function NewScreen () {\n  return (\n    <View>\n      <Text>This is New Screen</Text>\n    </View>\n  )\n}\n\nSimilar to HomeScreen, we're just showing the text \"This is New Screen\" for now.\n\nAdd Route for New Screen\nNow, we need to add a new route in our navigation stack for the new route. In \nApp.js below the Screen component for HomeScreen add a new one for NewScreen:\n\n<Stack.Screen name=\"New\" component={NewScreen} />\n\nAdd Header Button\nNext, we'll add a header button on the Home screen. It will be a plus button\nthat should take us to NewScreen.\n\nTo add a button to the header of a screen, we do it using the headerRight \nproperty of the options prop passed to Screen. The headerRight property accepts\na function that should return a component to render.\n\nInstead of using React Native's Button [https://reactnative.dev/docs/button] \ncomponent, we'll use React Native Elements [https://reactnativeelements.com]' \nIcon [https://reactnativeelements.com/docs/icon] component. Adding a plus icon\nlooks better than an actual button.\n\nSo, let's first install React Native Elements in our project:\n\nnpm i react-native-elements\n\nThen, change the following line in App.js:\n\n<Stack.Screen name=\"Home\" component={HomeScreen} />\n\nto this:\n\n<Stack.Screen \n    name=\"Home\" \n    component={HomeScreen} \n    options={{\n         headerRight: () => (\n             <Icon \n             name=\"plus\" \n             type=\"feather\" \n             color=\"#fff\"\n             style={style.headerIcon}\n         />\n    )\n    }}\n/>\n\nAs you can see, we are using the Icon component, passing it the prop name which\nis the name of the icon to be used. type as React Native Elements allow us to\nchoose from multiple icon sets. We are using Feather [https://feathericons.com] \nicons. color indicates the color of the icon. And finally, we're passing it \nstyle. Add the following to the end of App.js to create a new stylesheet:\n\nconst style = StyleSheet.create({\n  headerIcon: {\n    marginRight: 10\n  }\n});\n\nThis will add a margin-right to the icon, as it won't have any by default.\n\nIf you run the app now, you'll see that a new + icon has been added to the\nheader but it does nothing at the moment.\n\nNavigating to Another Screen\nWe need to navigate to NewScreen when the plus icon is pressed.\n\nIn React Native, button's press events are handled by passing a listener in the \nonPress prop of the button. So, we'll need to pass a handler for onPress to Icon\n.\n\nTo navigate to another screen, we can use the navigation prop. The navigation \nprop is passed to every screen in the stack navigation. \n\nAnother way we can use the navigation prop is by changing the value that the \noptions prop accepts of a Screen to a function. The function accepts as a\nparameter an object which contains navigation, and the function should return an\nobject of options.\n\nThen, using the navigation prop we can navigate to another screen with the \nnavigate method:\n\nnavigation.navigate('New')\n\nWhere navigate accepts the name of the screen we're navigating to.\n\nSo, change the line for HomeScreen in App.js to the following:\n\n<Stack.Screen \n    name=\"Home\" \n    component={HomeScreen} \n    options={({navigation}) => ({\n        headerRight: () => (\n            <Icon \n            name=\"plus\" \n            type=\"feather\" \n            color=\"#fff\"\n            style={style.headerIcon}\n                                onPress={() => navigation.navigate('New')}\n    \t\t/>\n    \t)\n    })}\n/>\n\nIf you open the app now and click on the plus icon, you'll be taken to NewScreen\n.\n\nYou can also see that, by default, a back button is added to the header and you\ncan use it to go backward in the navigation stack. If you click on it, you'll go\nback to the Home screen.\n\nNew Todo Item Form\nNext, we'll add a form to add a new todo item in NewScreen. To simplify creating\na form, we'll use Formik [https://formik.org].\n\nIf you're not familiar with Formik, it's a React and React Native library that\naims to simplify the process of creating a form.\n\nTo install Formik, run the following command:\n\nnpm install formik --save\n\nThen, change the content of src/screens/NewScreen.js to the following:\n\nimport { Formik } from 'formik';\nimport React from 'react';\nimport { StyleSheet, View } from 'react-native';\nimport { Text } from 'react-native-elements';\nimport { Button } from 'react-native-elements/dist/buttons/Button';\nimport { Input } from 'react-native-elements/dist/input/Input';\n\nexport default function NewScreen () {\n\n  function newTask (values) {\n\t//TODO save new task\n  }\n\n  return (\n    <Formik\n      initialValues={{title: ''}}\n      onSubmit={newTask}\n    >\n      {({handleChange, handleBlur, handleSubmit, values}) => (\n        <View style={style.container}>\n          <Text h4>New Todo Item</Text>\n          <Input \n            placeholder=\"Example: Cook, Clean, etc...\" \n            onChangeText={handleChange('title')}\n            onBlur={handleBlur('title')}\n            style={style.input}\n          />\n          <Button title=\"Add\" onPress={handleSubmit} style={style.button} />\n        </View>\n      )}\n    </Formik>\n  )\n}\n\nconst style = StyleSheet.create({\n  container: {\n    marginTop: 10,\n    padding: 10\n  },\n  input: {\n    marginTop: 10\n  },\n  button: {\n    backgroundColor: '#228CDB'\n  }\n})\n\nLet's go over everything we just added. We first define a new function newTask \ninside the component, which we'll use later to handle saving a new task.\n\nThen, we're creating a form with Formik. In Formik, you can use the Formik \ncomponent and pass it initialValues to define the fields and their initial\nvalues. We just have one field title and its initial value is just an empty\nstring.\n\nWe also pass the Formik component an onSubmit prop which is the function that\nshould be executed when the form is submitted. We're passing it newTask.\n\nInside the Formik component, you use a function that has a set of parameters but\nmost importantly are handleChange, handleBlur, handleSubmit, and values. The\nfunction should return a component to render.\n\nIf you're familiar with Formik when using it with React, you'll notice that this\nis slightly different than how you'd use it with React. As inputs in React\nNative are not similar to inputs on the web since they don't have names, you\nneed to clearly specify for each input the onChange and onBlur listeners passing\nthem the name of the input.\n\nSo, for the title Input [https://reactnativeelements.com/docs/input], which is a\ncomponent we are using from React Native Elements, we pass for onChange the\nlistener handleChange('title') and for onBlur the listener handleBlur('title').\n\nThen, we add a Button [https://reactnativeelements.com/docs/button] component,\nwhich is another component we are using from React Native Elements. We assign\nthe listener for onPress on the button to handleSubmit. This means that when the\nbutton is pressed, the submit event will be triggered in the form, which will\ntrigger newTask since we assigned it as the listener to onSubmit.\n\nNotice that we are adding some styling to the screen and components in it. We\nuse the styles variable which is created with StyleSheet.create, and we pass to\neach component a style prop with its value a property in the styles variable.\nFor example in View:\n\n<View style={style.container}>\n\nIf you open the app now, click on the plus button in the Home Screen which will\nopen NewScreen. You should see the form we just created.\n\nHandle Submit\nWe'll now handle the submission of the form in the function newTask. What we'll\ndo is take the title and store it in the app.\n\nThere are many ways you can manage storage in React Native. We'll use Async\nStorage [https://react-native-async-storage.github.io/async-storage/]. It\nprovides a simple API to store data in your app. For data that are not too\ncomplex, like settings related to the user or app, it's a great choice.\n\nWe'll use Async Storage to store the todo list items in our app. So, let's first\ninstall it:\n\nexpo install @react-native-async-storage/async-storage\n\nAsyncStorage has 2 functions in its API. getItem and setItem. using setItem, you\nset items serialized as strings. So, if you have an array or object you need to\nstringify them with JSON.stringify. Then, you can retrieve the item with getItem \nand you'll have to parse the JSON if it's stringified with JSON.parse.\n\nAdd the following import at the beginning of NewScreen.js along with the rest of\nthe imports added before:\n\nimport { useAsyncStorage } from '@react-native-async-storage/async-storage';\n\nThen, inside the NewScreen component, add the following line:\n\nconst { getItem, setItem } = useAsyncStorage('todo');\n\nWe are using the useAsyncStorage\n[https://react-native-async-storage.github.io/async-storage/docs/api#useasyncstorage] \nhook which allows us to pass the name of a key in the storage and retrieve a\ngetter getItem and a setter setItem solely for that key in the storage.\n\nBefore we start implementing the functionality inside newTask, we need 2 other\ndependencies: react-native-uuid\n[https://www.npmjs.com/package/react-native-uuid] to generate random IDs for\nevery task in storage, and react-native-toast-message\n[https://www.npmjs.com/package/react-native-toast-message] to show toast\nmessages if an error occurs:\n\nnpm i react-native-uuid react-native-toast-message\n\nFor react-native-toast-message to work, we first need to add a Toast component\nin one of the higher components rendered in the App. So, add the following line\nin App.js before the closing of NavigationContainer:\n\n\t<Toast ref={(ref) => Toast.setRef(ref)} />\n</NavigationContainer>\n\nAnd, of course, add the necessary import at the beginning of App.js:\n\nimport Toast from 'react-native-toast-message';\n\nBack to NewScreen.js. We'll now implement newTask. We'll first validate that the\nuser entered a value for title. Then, we'll get the todo items from the storage,\nwhich will be an array of objects where each object is a to-do item. Then, we'll\npush a new item into the array and set the item in storage again.\n\nChange the newTask function to the following:\n\nfunction newTask (values) {\n    if (!values.title) {\n      Toast.show({\n        type: 'error',\n        text1: 'Title is required',\n        position: 'top'\n      });\n      return;\n    }\n    //get todo array from storage\n    getItem()\n      .then((todoJSON) => {\n        let todo = todoJSON ? JSON.parse(todoJSON) : [];\n        //add a new item to the list\n        todo.push({\n          id: uuid.v4(),\n          title: values.title\n        });\n\n        //set item in storage again\n        setItem(JSON.stringify(todo))\n          .then(() => {\n            //navigate back to home screen\n            navigation.goBack();\n          }).catch((err) => {\n            console.error(err);\n            Toast.show({\n              type: 'error',\n              text1: 'An error occurred and a new item could not be saved',\n              position: 'top'\n            });\n          });\n      })\n      .catch((err) => {\n        console.error(err);\n        Toast.show({\n          type: 'error',\n          text1: 'An error occurred and a new item could not be saved',\n          position: 'bottom'\n        });\n      });\n  }\n\nAs you can see, we're checking first if values.title has been entered. If not,\nwe show a toast message and return. To show a toast message using\nreact-native-toast-message you need to pass it an object of options. There are a\nvariety of options you can use, but the most important here are type which can\nbe error, success, or info, position which can be top or bottom, and text1 which\nwill be the message to show in the toast.\n\nAfter validating title, we then use getItem to retrieve todo from the storage if\nit exists. getItem returns a Promise as it is asynchronous, and the value of \ntodo is passed to then function handler.\n\nInside then we parse the JSON, then push a new to-do item. Each todo item will\nhave an id which is randomly generated, and a title.\n\nFinally, we set the todo array in the storage again as JSON. Once it is set\nsuccessfully, we navigate back to the Home screen with navigation.goBack. As we\nmentioned earlier, all items in the navigation stack receive navigation as a\nprop. So, make sure to add the prop for NewScreen:\n\nexport default function NewScreen ({ navigation }) {\n\nYou can now try the form. Open the app and go to the NewScreen. Try first to\nsubmit the form without entering a title. You should see then a message telling\nyou that the Title is required.\n\nNow try to enter a title and press \"Add\". You'll be navigated back to the Home\nScreen. That means that the item was added successfully!\n\nWhat's left for us to do is display them on the Home Screen.\n\nDisplay Tasks\nWe'll now change the content of the Home Screen to display the todo list items\nwe are adding in NewScreen.\n\nTo do so, we'll use the same function we used in NewScreen from Async Storage to\nget the items. To display the items, we'll use FlatList\n[https://reactnative.dev/docs/flatlist], a component that allows us to display a\nlist of items easily.\n\nChange the content of HomeScreen to the following:\n\nimport { useAsyncStorage } from '@react-native-async-storage/async-storage';\nimport React, { useEffect, useState } from 'react';\nimport { FlatList, StyleSheet, Text, View } from 'react-native';\nimport { Card } from 'react-native-elements';\nimport Toast from 'react-native-toast-message';\n\nexport default function HomeScreen ({ navigation }) {\n  const { getItem } = useAsyncStorage('todo');\n  const [items, setItems] = useState([]);\n  const [loading, setLoading] = useState(true);\n\n  function getTodoList () {\n    getItem()\n      .then((todoJSON) => {\n        const todo = todoJSON ? JSON.parse(todoJSON) : [];\n        setItems(todo);\n        setLoading(false);\n      })\n      .catch((err) => {\n        console.error(err);\n        Toast.show({\n          type: 'error',\n          text1: 'An error occurred',\n          position: 'top'\n        });\n      });\n  }\n\n  function renderCard ({item}) {\n    return (\n      <Card>\n        <Card.Title style={styles.cardTitle}>{item.title}</Card.Title>\n      </Card>\n    )\n  }\n  \n  useEffect(() => {\n    const unsubscribe = navigation.addListener('focus', getTodoList);\n\n    return unsubscribe;\n  }, [])\n\n  return (\n    <View>\n      <FlatList refreshing={loading} onRefresh={getTodoList} style={styles.list} data={items} \n        renderItem={renderCard} keyExtractor={(item) => item.id} />\n    </View>\n  )\n}\n\nconst styles = StyleSheet.create({\n  list: {\n    width: '100%'\n  },\n  cardTitle: {\n    textAlign: 'left'\n  }\n})\n\nHere's a breakdown of what this code is doing. First, we're using \nuseAsyncStorage hook just like we did before to get a getter function for todo.\nWe're also creating state variables items and loading. items will be used to\nstore the items after fetching them from the storage. loading will be used to\nindicate that we're currently retrieving the items from the storage.\n\nThen, we create the function getTodoList. This function should be executed every\ntime the screen is opened. In this function, we're just using the getter\nfunction getItem like we did before and once we retrieve the todo list items\nfrom the storage, we're setting the state items and loading.\n\nAfter that, we create the function renderCard. This function will be used to\nrender each item in the FlatList. We'll be using the Card\n[https://reactnativeelements.com/docs/card] component from React Native Element\nto display them.\n\nNext is the important part. In useEffect, we are adding an event listener to the \nfocus event for the navigator object that the screens inside the navigation\nstack receive as a prop. The focus event is triggered every time the screen\ncomes into focus. So, this listener for the focus event will run when the app\nlaunch and the Home screen is shown, and when we go back from the NewScreen to\nthe Home screen.\n\nFinally, we're displaying the FlatList component. It receives the refreshing \nprop which indicates whether the list is currently refreshing. We're passing it\nthe loading state. We're also passing it an event handler for the refresh event\nin the prop onRefresh. This event is triggered whenever the user refreshes the\nlist by pulling it down.\n\nThe data prop indicates the data that we're displaying in the list and should be\nan array. The renderItem prop receives a function to render each item, and that\nfunction will be passed an object which includes the item property, indicating\nthe current item to be rendered in the list. \n\nThe keyExtractor prop indicates how to assign the key prop for each item in the\nlist. In React and React Native, when rendering an array of items you should\npass a key prop to each item. We're setting the key for each item its id.\n\nIn the end, we're defining the stylesheet to style all elements.\n\n If you open the app now, you'll see that on the Home Screen a list of items\nwill appear which are items that you add in the NewScreen. Try going to the \nNewScreen again and adding more items. You'll see them added to the list.\n\nPublish the App\nThe last step that comes when creating an app is to publish it. React Native's\ndocumentation has a guide on how to publish your app on Google Play Store\n[https://reactnative.dev/docs/signed-apk-android] and Apple App Store\n[https://reactnative.dev/docs/publishing-to-app-store].\n\nIf, however, you want to publish the app but you don't have a developer account\nfor either Google or Apple, you can publish the app on Expo\n[https://docs.expo.dev/workflow/publishing/], but that would require anyone to\ninstall Expo to be able to try or use your app.\n\nConclusion\nYou just created your first app! You were able to create an app with navigation,\nforms, storage, lists, and more!\n\nIf you want to keep practicing, try adding a delete or edit functionality. Make\nsure to check more of React Native's documentation [https://reactnative.dev] as\nwell as React Navigation's documentation on how to pass parameters\n[https://reactnavigation.org/docs/params] as well.","html":"<p><a href=\"https://reactnative.dev\">React Native</a> is one of the most popular frameworks that allow you to create cross-platform apps using JavaScript. Using React Native, you'll be able to write one code for the web, iOS, and Android.</p><p>In this tutorial, you'll learn the basics of creating a React Native app with <a href=\"https://expo.dev\">Expo</a>. We'll create a to-do list app where we'll learn about implementing navigation in a React Native app and storing data in our app.</p><p>You can find the code for this tutorial in <a href=\"https://github.com/shahednasser/react-native-tutorial\">this GitHub Repository</a>. You can also <a href=\"https://expo.dev/@shahednasser/todolist\">install the app</a> using Expo Go. There is more info on how to install Expo Go below.</p><h2 id=\"prerequisites\">Prerequisites</h2><p>Before you start going through the tutorial, you'll need to install <a href=\"https://nodejs.org/en/\">Node.js</a> which will install NPM with it.</p><p>You also need to install Expo. Expo provides a set of tools to make your mobile development with React Native easier. </p><p>To install Expo run:</p><pre><code class=\"language-bash\">npm install -g expo-cli</code></pre><p>Finally, you'll need to install <a href=\"https://expo.dev/client\">Expo Go</a> on your phone. It's available for both <a href=\"https://play.google.com/store/apps/details?id=host.exp.exponent&amp;hl=en&amp;gl=US\">Android</a> and <a href=\"https://apps.apple.com/us/app/expo-go/id982107779\">iOS</a>.</p><p>By installing Expo Go on your phone, you'll be able to test your app directly on your phone as you make changes. </p><h2 id=\"setup-project\">Setup Project</h2><p>To create a new React Native project, run the following command in your terminal:</p><pre><code class=\"language-bash\">expo init todolist</code></pre><p>You'll be asked to choose the kind of project you want to create, choose <code>blank</code>.</p><p>After you choose <code>blank</code>, the project will be set up and the minimal dependencies required to create an app with React Native will be installed.</p><p>After the setup is done, change to the directory of the project:</p><pre><code class=\"language-bash\">cd todolist</code></pre><h2 id=\"project-structure\">Project Structure</h2><p>Let's take a quick look at the project's structure before we start coding.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/09/Screen-Shot-2021-09-25-at-9.56.47-PM.png\" class=\"kg-image\" alt loading=\"lazy\" width=\"548\" height=\"578\"></figure><p>We have the usual <code>package.json</code> files that you find in every NPM project.</p><p>There's <code>app.json</code>. This includes a set of configurations for our app. If you open it, you'll find key-value pairs related to the app name, version, icon, splash screen, and more.</p><p><code>App.js</code> is the entry point of our app. It's where we will start writing our app's code.</p><p>The <code>assets</code> directory includes images like the app icon, splash screen, and more.</p><h3 id=\"understand-first-components-in-react-native\">Understand First Components in React Native</h3><p>If you open <code>App.js</code>, you'll find content similar to this:</p><pre><code class=\"language-js\">import { StatusBar } from 'expo-status-bar';\nimport React from 'react';\nimport { StyleSheet, Text, View } from 'react-native';\n\nexport default function App() {\n  return (\n    &lt;View style={styles.container}&gt;\n      &lt;Text&gt;Open up App.js to start working on your app!&lt;/Text&gt;\n      &lt;StatusBar style=\"auto\" /&gt;\n    &lt;/View&gt;\n  );\n}\n\nconst styles = StyleSheet.create({\n  container: {\n    flex: 1,\n    backgroundColor: '#fff',\n    alignItems: 'center',\n    justifyContent: 'center',\n  },\n});\n</code></pre><p>This is our first component! As you can see, components like <code>View</code>, <code>Text</code> and others imported from <code>react-native</code> are being used.</p><p>You should know that in React Native when displaying the text you need to do it inside a <code>Text</code> component. </p><p>React Native provides a set of components that will be later transformed into native components in iOS or Android.</p><p>We also create stylesheets to add styling to our components using <code>StyleSheet.create</code>, where <code>StyleSheet</code> is imported from <code>react-native</code> as well.</p><p>The <code>create</code> method takes an object of properties, which act like class names in CSS, and their values are objects of CSS-like properties and their values. Styling your components in React Native is almost identical to styling using CSS, with a few changes in some behaviors of some CSS properties.</p><h2 id=\"screens-and-navigation\">Screens and Navigation</h2><p>Now, we'll start adding screens to our app. To add different screens and manage navigation between them, we'll use <a href=\"https://reactnavigation.org/\">React Navigation</a>.</p><p>For an elaborate tutorial on Navigation, check out my tutorial <a href=\"https://blog.shahednasser.com/react-native-navigation-tutorial/\">React Native Navigation Tutorial</a>.</p><h3 id=\"home-screen\">Home Screen</h3><p>Create the directories <code>src/screens</code>. The <code>screens</code> directory will hold all the screens we will create later on.</p><p>Then, create <code>HomeScreen.js</code> inside <code>screens</code>. This will be the first screen that the user will see when they open the app.</p><p>Add the following content inside <code>HomeScreen.js</code>:</p><pre><code class=\"language-js\">import React from 'react';\nimport { Text, View } from 'react-native';\n\nexport default function HomeScreen () {\n  return (\n    &lt;View&gt;\n      &lt;Text&gt;Welcome Home!&lt;/Text&gt;\n    &lt;/View&gt;\n  )\n}</code></pre><p>The home screen, at the moment, will just display the text \"Welcome Home!\".</p><h3 id=\"install-react-navigation\">Install React Navigation</h3><p>Next, we'll see how to use multiple screens with React Navigation.</p><p>React Navigation allows us to move between screens backward and forwards, add buttons to the header, and more.</p><p>To install React Navigation, run the following commands:</p><pre><code class=\"language-bash\">npm install @react-navigation/native\nexpo install react-native-screens react-native-safe-area-context\nnpm install @react-navigation/native-stack</code></pre><p>Once these commands are done executing, we'll have all the dependencies required to use React Navigation.</p><h3 id=\"how-react-navigation-works\">How React Navigation Works</h3><p>To put things simply, React Navigation manages screens, navigation between them, and history as a Stack. </p><p>There's a default, initial screen that shows when the app is launched. Then, when you want to open a new screen, you can push it at the top of the stack or replace the current item in the stack.</p><p>Then, when you want to go backward, you pop the current item at the top of the stack and show the one below it, which was the previous screen, until you reach the home, initial screen.</p><p> If it sounds confusing at the moment, keep going through in the tutorial and you'll start understanding things more.</p><h3 id=\"create-the-navigation-stack\">Create the Navigation Stack</h3><p>Change the content of <code>App.js</code> to the following:</p><pre><code class=\"language-js\">import 'react-native-gesture-handler';\nimport React from 'react';\nimport { createStackNavigator } from '@react-navigation/stack';\nimport { NavigationContainer } from '@react-navigation/native';\nimport HomeScreen from './src/screens/HomeScreen';\n\nconst Stack = createStackNavigator();\n\nexport default function App() {\n  return (\n    &lt;NavigationContainer&gt;\n      &lt;Stack.Navigator initialRouteName=\"Home\"&gt;\n        &lt;Stack.Screen name=\"Home\" component={HomeScreen} /&gt;\n      &lt;/Stack.Navigator&gt;\n    &lt;/NavigationContainer&gt;\n  );\n}\n</code></pre><p>Let's go over things bit by bit.</p><p>We first need to import <code>react-native-gesture-handler</code> at the top of the app. This allows navigating using gestures. The higher in the app it's placed the better.</p><p>Next, we're importing <code>createStackNavigator</code>. This function returns a Stack object, which contains two components <code>Screen</code> and <code>Navigator</code>. </p><p><code>Screen</code> is used to display screen components that we create, define their options, and more. If you look at the example above, we provide a <code>name</code> and <code>component</code> props for a screen:</p><pre><code class=\"language-js\">&lt;Stack.Screen name=\"Home\" component={HomeScreen} /&gt;</code></pre><p>The <code>name</code> prop can be used to navigate to that screen at any given point later. The <code>component</code> prop will be used to define the screen component to render when the screen is navigated to.</p><p><code>Navigator</code> should contain <code>Screen</code> components as children as it manages the routing between them. <code>Navigator</code> also receives the <code>initialRouteName</code> prop which determines the screen that should open when the app first launches.</p><p>Finally, we use <code>NavigationContainer</code> to wrap the <code>Navigator</code> components, as it manages the navigation tree and state.</p><p>So, in <code>App.js</code>, which will contain the navigation routes for the screens in the app as we go forward, we should render the <code>NavigationContainer</code> and inside it <code>Stack.Navigator</code> which contains one or more <code>Stack.Screen</code> components:</p><pre><code class=\"language-js\">&lt;NavigationContainer&gt;\n    &lt;Stack.Navigator initialRouteName=\"Home\"&gt;\n        &lt;Stack.Screen name=\"Home\" component={HomeScreen} /&gt;\n    &lt;/Stack.Navigator&gt;\n&lt;/NavigationContainer&gt;</code></pre><h2 id=\"run-the-app\">Run the App</h2><p>Let's run the app now. To do that, open the terminal and run the following:</p><pre><code class=\"language-bash\">npm start</code></pre><p>This will start Expo. As mentioned earlier, with Expo you will be able to run the app on your phone, so make sure you've installed Expo Go as detailed in the Prerequisites section.</p><p>A web page will open that looks something like this:</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/09/Screen-Shot-2021-09-26-at-3.16.27-PM.png\" class=\"kg-image\" alt loading=\"lazy\" width=\"2000\" height=\"1172\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/09/Screen-Shot-2021-09-26-at-3.16.27-PM.png 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/09/Screen-Shot-2021-09-26-at-3.16.27-PM.png 1000w, https://backend.shahednasser.com/content/images/size/w1600/2021/09/Screen-Shot-2021-09-26-at-3.16.27-PM.png 1600w, https://backend.shahednasser.com/content/images/size/w2400/2021/09/Screen-Shot-2021-09-26-at-3.16.27-PM.png 2400w\" sizes=\"(min-width: 720px) 720px\"></figure><p>There are multiple ways to run the app after this on your device. You can scan the QR code with your phone to open it in Expo Go. Alternatively, you can use one of the actions on the sidebar of the web page above like send link with email and so on.</p><p>Once you choose the best way to open the app on your phone and it opens, you should see the following screen:</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/09/IMG_7813.PNG\" class=\"kg-image\" alt loading=\"lazy\" width=\"1242\" height=\"2208\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/09/IMG_7813.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/09/IMG_7813.PNG 1000w, https://backend.shahednasser.com/content/images/2021/09/IMG_7813.PNG 1242w\" sizes=\"(min-width: 720px) 720px\"></figure><p>We've run our first app! We'll start customizing the styles of the header next and add more screens to create a Todo List app.</p><h2 id=\"style-the-header\">Style the Header</h2><p>With React Navigation, there are 2 ways to style the header of a screen.</p><h3 id=\"style-screen-headers-individually\">Style Screen Headers Individually</h3><p>The first way is to style it for each screen. This can be done by passing the <code>options</code> prop to a <code>Screen</code> component like this:</p><pre><code class=\"language-js\">&lt;Stack.Screen \n    name=\"Home\" \n    component={HomeScreen} \n    options={{\n\t\theaderStyle: {\n\t\t\tbackgroundColor: '#228CDB'\n\t\t},\n        headerTintColor: '#fff'\n    }} \n/&gt;</code></pre><p>The <code>options</code> prop is an object of options for the screen. To style the header, we can use the following three properties:</p><ol><li><code>headerStyle</code>: accepts an object of styles to apply to the header. To set the background color of the header, we pass it the <code>backgroundColor</code> prop with the value of the background color of the header.</li><li><code>headerTintColor</code>: the color of the text or buttons that are in the header.</li><li><code>headerTitleStyle</code>: accepts an object of font-related styles to make changes to the title in the header. For example, we can change the <code>fontFamily</code> or <code>fontWeight</code>.</li></ol><p>Using this prop, we'll be able to style the header of a screen.</p><h3 id=\"style-all-screen-headers\">Style All Screen Headers</h3><p>In general cases, styling each screen separately is tedious and leads to repeated code. Usually, you'd apply the same header style to all screens in the app.</p><p>In this case, we can use the <code>screenOptions</code> prop on the <code>Navigator</code> component. This prop accepts the same header options as the <code>options</code> prop in the <code>Screen</code> component and applies the styling to all screens.</p><h3 id=\"apply-header-styles-in-our-app\">Apply Header Styles in Our App</h3><p>In our app, we'll apply the same header style to all the screens in the app. So, we'll use the second way to style a header.</p><p>In App.js, replace this line:</p><pre><code class=\"language-js\">&lt;Stack.Navigator initialRouteName=\"Home\"&gt;</code></pre><p>With the following:</p><pre><code class=\"language-js\">&lt;Stack.Navigator\n    screenOptions={{\n\t\t\theaderStyle: {\n\t\t\t\tbackgroundColor: '#228CDB'\n\t\t\t},\n        \theaderTintColor: '#fff'\n    \t}} \n    initialRouteName=\"Home\"&gt;</code></pre><p>This will change the background color of the header to <code>#228CDB</code> and the color of the text and buttons in the header to <code>#fff</code>.</p><p>If you save the changes and open the app again, you'll see that the header color changed.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/09/IMG_7814.PNG\" class=\"kg-image\" alt loading=\"lazy\" width=\"1242\" height=\"2208\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/09/IMG_7814.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/09/IMG_7814.PNG 1000w, https://backend.shahednasser.com/content/images/2021/09/IMG_7814.PNG 1242w\" sizes=\"(min-width: 720px) 720px\"></figure><h2 id=\"navigate-screens\">Navigate Screens</h2><p>Next, we'll see how to add another screen and navigate to it. We'll also see how to add a header button.</p><h3 id=\"add-new-screen\">Add New Screen</h3><p>We'll add a new screen, which we'll use later to add a new to-do list item. </p><p>Create <code>src/screens/NewScreen.js</code> with the following content:</p><pre><code class=\"language-js\">import React from 'react';\nimport { Text, View } from 'react-native';\n\nexport default function NewScreen () {\n  return (\n    &lt;View&gt;\n      &lt;Text&gt;This is New Screen&lt;/Text&gt;\n    &lt;/View&gt;\n  )\n}</code></pre><p>Similar to <code>HomeScreen</code>, we're just showing the text \"This is New Screen\" for now.</p><h3 id=\"add-route-for-new-screen\">Add Route for New Screen</h3><p>Now, we need to add a new route in our navigation stack for the new route. In <code>App.js</code> below the <code>Screen</code> component for <code>HomeScreen</code> add a new one for <code>NewScreen</code>:</p><pre><code class=\"language-js\">&lt;Stack.Screen name=\"New\" component={NewScreen} /&gt;</code></pre><h3 id=\"add-header-button\">Add Header Button</h3><p>Next, we'll add a header button on the Home screen. It will be a plus button that should take us to <code>NewScreen</code>.</p><p>To add a button to the header of a screen, we do it using the <code>headerRight</code> property of the <code>options</code> prop passed to <code>Screen</code>. The <code>headerRight</code> property accepts a function that should return a component to render.</p><p>Instead of using React Native's <a href=\"https://reactnative.dev/docs/button\">Button</a> component, we'll use <a href=\"https://reactnativeelements.com\">React Native Elements</a>' <a href=\"https://reactnativeelements.com/docs/icon\">Icon</a> component. Adding a plus icon looks better than an actual button.</p><p>So, let's first install React Native Elements in our project:</p><pre><code class=\"language-bash\">npm i react-native-elements</code></pre><p>Then, change the following line in <code>App.js</code>:</p><pre><code class=\"language-js\">&lt;Stack.Screen name=\"Home\" component={HomeScreen} /&gt;</code></pre><p>to this:</p><pre><code class=\"language-js\">&lt;Stack.Screen \n    name=\"Home\" \n    component={HomeScreen} \n    options={{\n         headerRight: () =&gt; (\n             &lt;Icon \n             name=\"plus\" \n             type=\"feather\" \n             color=\"#fff\"\n             style={style.headerIcon}\n         /&gt;\n    )\n    }}\n/&gt;</code></pre><p>As you can see, we are using the Icon component, passing it the prop <code>name</code> which is the name of the icon to be used. <code>type</code> as React Native Elements allow us to choose from multiple icon sets. We are using <a href=\"https://feathericons.com\">Feather</a> icons. <code>color</code> indicates the color of the icon. And finally, we're passing it <code>style</code>. Add the following to the end of <code>App.js</code> to create a new stylesheet:</p><pre><code class=\"language-js\">const style = StyleSheet.create({\n  headerIcon: {\n    marginRight: 10\n  }\n});</code></pre><p>This will add a margin-right to the icon, as it won't have any by default.</p><p>If you run the app now, you'll see that a new + icon has been added to the header but it does nothing at the moment.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/09/IMG_7817.PNG\" class=\"kg-image\" alt loading=\"lazy\" width=\"1242\" height=\"2208\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/09/IMG_7817.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/09/IMG_7817.PNG 1000w, https://backend.shahednasser.com/content/images/2021/09/IMG_7817.PNG 1242w\" sizes=\"(min-width: 720px) 720px\"></figure><h3 id=\"navigating-to-another-screen\">Navigating to Another Screen</h3><p>We need to navigate to <code>NewScreen</code> when the plus icon is pressed.</p><p>In React Native, button's press events are handled by passing a listener in the <code>onPress</code> prop of the button. So, we'll need to pass a handler for <code>onPress</code> to <code>Icon</code>.</p><p>To navigate to another screen, we can use the <code>navigation</code> prop. The <code>navigation</code> prop is passed to every screen in the stack navigation. </p><p>Another way we can use the <code>navigation</code> prop is by changing the value that the <code>options</code> prop accepts of a <code>Screen</code> to a function. The function accepts as a parameter an object which contains <code>navigation</code>, and the function should return an object of options.</p><p>Then, using the <code>navigation</code> prop we can navigate to another screen with the <code>navigate</code> method:</p><pre><code class=\"language-js\">navigation.navigate('New')</code></pre><p>Where <code>navigate</code> accepts the name of the screen we're navigating to.</p><p>So, change the line for <code>HomeScreen</code> in <code>App.js</code> to the following:</p><pre><code class=\"language-js\">&lt;Stack.Screen \n    name=\"Home\" \n    component={HomeScreen} \n    options={({navigation}) =&gt; ({\n        headerRight: () =&gt; (\n            &lt;Icon \n            name=\"plus\" \n            type=\"feather\" \n            color=\"#fff\"\n            style={style.headerIcon}\n                                onPress={() =&gt; navigation.navigate('New')}\n    \t\t/&gt;\n    \t)\n    })}\n/&gt;</code></pre><p>If you open the app now and click on the plus icon, you'll be taken to <code>NewScreen</code>.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/09/IMG_7818.PNG\" class=\"kg-image\" alt loading=\"lazy\" width=\"1242\" height=\"2208\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/09/IMG_7818.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/09/IMG_7818.PNG 1000w, https://backend.shahednasser.com/content/images/2021/09/IMG_7818.PNG 1242w\" sizes=\"(min-width: 720px) 720px\"></figure><p>You can also see that, by default, a back button is added to the header and you can use it to go backward in the navigation stack. If you click on it, you'll go back to the Home screen.</p><h2 id=\"new-todo-item-form\">New Todo Item Form</h2><p>Next, we'll add a form to add a new todo item in <code>NewScreen</code>. To simplify creating a form, we'll use <a href=\"https://formik.org\">Formik</a>.</p><p>If you're not familiar with Formik, it's a React and React Native library that aims to simplify the process of creating a form.</p><p>To install Formik, run the following command:</p><pre><code class=\"language-bash\">npm install formik --save</code></pre><p>Then, change the content of <code>src/screens/NewScreen.js</code> to the following:</p><pre><code class=\"language-js\">import { Formik } from 'formik';\nimport React from 'react';\nimport { StyleSheet, View } from 'react-native';\nimport { Text } from 'react-native-elements';\nimport { Button } from 'react-native-elements/dist/buttons/Button';\nimport { Input } from 'react-native-elements/dist/input/Input';\n\nexport default function NewScreen () {\n\n  function newTask (values) {\n\t//TODO save new task\n  }\n\n  return (\n    &lt;Formik\n      initialValues={{title: ''}}\n      onSubmit={newTask}\n    &gt;\n      {({handleChange, handleBlur, handleSubmit, values}) =&gt; (\n        &lt;View style={style.container}&gt;\n          &lt;Text h4&gt;New Todo Item&lt;/Text&gt;\n          &lt;Input \n            placeholder=\"Example: Cook, Clean, etc...\" \n            onChangeText={handleChange('title')}\n            onBlur={handleBlur('title')}\n            style={style.input}\n          /&gt;\n          &lt;Button title=\"Add\" onPress={handleSubmit} style={style.button} /&gt;\n        &lt;/View&gt;\n      )}\n    &lt;/Formik&gt;\n  )\n}\n\nconst style = StyleSheet.create({\n  container: {\n    marginTop: 10,\n    padding: 10\n  },\n  input: {\n    marginTop: 10\n  },\n  button: {\n    backgroundColor: '#228CDB'\n  }\n})</code></pre><p>Let's go over everything we just added. We first define a new function <code>newTask</code> inside the component, which we'll use later to handle saving a new task.</p><p>Then, we're creating a form with Formik. In Formik, you can use the <code>Formik</code> component and pass it <code>initialValues</code> to define the fields and their initial values. We just have one field <code>title</code> and its initial value is just an empty string.</p><p>We also pass the <code>Formik</code> component an <code>onSubmit</code> prop which is the function that should be executed when the form is submitted. We're passing it <code>newTask</code>.</p><p>Inside the <code>Formik</code> component, you use a function that has a set of parameters but most importantly are <code>handleChange</code>, <code>handleBlur</code>, <code>handleSubmit</code>, and <code>values</code>. The function should return a component to render.</p><p>If you're familiar with Formik when using it with React, you'll notice that this is slightly different than how you'd use it with React. As inputs in React Native are not similar to inputs on the web since they don't have names, you need to clearly specify for each input the <code>onChange</code> and <code>onBlur</code> listeners passing them the name of the input.</p><p>So, for the title <a href=\"https://reactnativeelements.com/docs/input\">Input</a>, which is a component we are using from React Native Elements, we pass for <code>onChange</code> the listener <code>handleChange('title')</code> and for <code>onBlur</code> the listener <code>handleBlur('title')</code>.</p><p>Then, we add a <a href=\"https://reactnativeelements.com/docs/button\">Button</a> component, which is another component we are using from React Native Elements. We assign the listener for <code>onPress</code> on the button to <code>handleSubmit</code>. This means that when the button is pressed, the submit event will be triggered in the form, which will trigger <code>newTask</code> since we assigned it as the listener to <code>onSubmit</code>.</p><p>Notice that we are adding some styling to the screen and components in it. We use the <code>styles</code> variable which is created with <code>StyleSheet.create</code>, and we pass to each component a style prop with its value a property in the <code>styles</code> variable. For example in <code>View</code>:</p><pre><code class=\"language-js\">&lt;View style={style.container}&gt;</code></pre><p>If you open the app now, click on the plus button in the Home Screen which will open <code>NewScreen</code>. You should see the form we just created.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/09/IMG_7819.PNG\" class=\"kg-image\" alt loading=\"lazy\" width=\"1242\" height=\"2208\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/09/IMG_7819.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/09/IMG_7819.PNG 1000w, https://backend.shahednasser.com/content/images/2021/09/IMG_7819.PNG 1242w\" sizes=\"(min-width: 720px) 720px\"></figure><h3 id=\"handle-submit\">Handle Submit</h3><p>We'll now handle the submission of the form in the function <code>newTask</code>. What we'll do is take the title and store it in the app.</p><p>There are many ways you can manage storage in React Native. We'll use <a href=\"https://react-native-async-storage.github.io/async-storage/\">Async Storage</a>. It provides a simple API to store data in your app. For data that are not too complex, like settings related to the user or app, it's a great choice.</p><p>We'll use Async Storage to store the todo list items in our app. So, let's first install it:</p><pre><code class=\"language-bash\">expo install @react-native-async-storage/async-storage</code></pre><p>AsyncStorage has 2 functions in its API. getItem and setItem. using setItem, you set items serialized as strings. So, if you have an array or object you need to stringify them with <code>JSON.stringify</code>. Then, you can retrieve the item with <code>getItem</code> and you'll have to parse the JSON if it's stringified with <code>JSON.parse</code>.</p><p>Add the following import at the beginning of <code>NewScreen.js</code> along with the rest of the imports added before:</p><pre><code class=\"language-js\">import { useAsyncStorage } from '@react-native-async-storage/async-storage';</code></pre><p>Then, inside the <code>NewScreen</code> component, add the following line:</p><pre><code class=\"language-js\">const { getItem, setItem } = useAsyncStorage('todo');</code></pre><p>We are using the <a href=\"https://react-native-async-storage.github.io/async-storage/docs/api#useasyncstorage\">useAsyncStorage</a> hook which allows us to pass the name of a key in the storage and retrieve a getter <code>getItem</code> and a setter <code>setItem</code> solely for that key in the storage.</p><p>Before we start implementing the functionality inside <code>newTask</code>, we need 2 other dependencies: <a href=\"https://www.npmjs.com/package/react-native-uuid\">react-native-uuid</a> to generate random IDs for every task in storage, and <a href=\"https://www.npmjs.com/package/react-native-toast-message\">react-native-toast-message</a> to show toast messages if an error occurs:</p><pre><code class=\"language-bash\">npm i react-native-uuid react-native-toast-message</code></pre><p>For react-native-toast-message to work, we first need to add a <code>Toast</code> component in one of the higher components rendered in the App. So, add the following line in <code>App.js</code> before the closing of <code>NavigationContainer</code>:</p><pre><code class=\"language-js\">\t&lt;Toast ref={(ref) =&gt; Toast.setRef(ref)} /&gt;\n&lt;/NavigationContainer&gt;</code></pre><p>And, of course, add the necessary import at the beginning of <code>App.js</code>:</p><pre><code class=\"language-js\">import Toast from 'react-native-toast-message';</code></pre><p>Back to <code>NewScreen.js</code>. We'll now implement <code>newTask</code>. We'll first validate that the user entered a value for <code>title</code>. Then, we'll get the <code>todo</code> items from the storage, which will be an array of objects where each object is a to-do item. Then, we'll push a new item into the array and set the item in storage again.</p><p>Change the <code>newTask</code> function to the following:</p><pre><code class=\"language-js\">function newTask (values) {\n    if (!values.title) {\n      Toast.show({\n        type: 'error',\n        text1: 'Title is required',\n        position: 'top'\n      });\n      return;\n    }\n    //get todo array from storage\n    getItem()\n      .then((todoJSON) =&gt; {\n        let todo = todoJSON ? JSON.parse(todoJSON) : [];\n        //add a new item to the list\n        todo.push({\n          id: uuid.v4(),\n          title: values.title\n        });\n\n        //set item in storage again\n        setItem(JSON.stringify(todo))\n          .then(() =&gt; {\n            //navigate back to home screen\n            navigation.goBack();\n          }).catch((err) =&gt; {\n            console.error(err);\n            Toast.show({\n              type: 'error',\n              text1: 'An error occurred and a new item could not be saved',\n              position: 'top'\n            });\n          });\n      })\n      .catch((err) =&gt; {\n        console.error(err);\n        Toast.show({\n          type: 'error',\n          text1: 'An error occurred and a new item could not be saved',\n          position: 'bottom'\n        });\n      });\n  }</code></pre><p>As you can see, we're checking first if <code>values.title</code> has been entered. If not, we show a toast message and return. To show a toast message using react-native-toast-message you need to pass it an object of options. There are a variety of options you can use, but the most important here are <code>type</code> which can be <code>error</code>, <code>success</code>, or <code>info</code>, <code>position</code> which can be <code>top</code> or <code>bottom</code>, and <code>text1</code> which will be the message to show in the toast.</p><p>After validating <code>title</code>, we then use <code>getItem</code> to retrieve <code>todo</code> from the storage if it exists. <code>getItem</code> returns a Promise as it is asynchronous, and the value of <code>todo</code> is passed to <code>then</code> function handler.</p><p>Inside <code>then</code> we parse the JSON, then push a new to-do item. Each todo item will have an <code>id</code> which is randomly generated, and a <code>title</code>.</p><p>Finally, we set the <code>todo</code> array in the storage again as JSON. Once it is set successfully, we navigate back to the Home screen with <code>navigation.goBack</code>. As we mentioned earlier, all items in the navigation stack receive <code>navigation</code> as a prop. So, make sure to add the prop for <code>NewScreen</code>:</p><pre><code class=\"language-js\">export default function NewScreen ({ navigation }) {</code></pre><p>You can now try the form. Open the app and go to the <code>NewScreen</code>. Try first to submit the form without entering a title. You should see then a message telling you that the Title is required.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/09/IMG_7841.PNG\" class=\"kg-image\" alt loading=\"lazy\" width=\"1242\" height=\"2208\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/09/IMG_7841.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/09/IMG_7841.PNG 1000w, https://backend.shahednasser.com/content/images/2021/09/IMG_7841.PNG 1242w\" sizes=\"(min-width: 720px) 720px\"></figure><p>Now try to enter a title and press \"Add\". You'll be navigated back to the Home Screen. That means that the item was added successfully!</p><p>What's left for us to do is display them on the Home Screen.</p><h3 id=\"display-tasks\">Display Tasks</h3><p>We'll now change the content of the Home Screen to display the todo list items we are adding in <code>NewScreen</code>.</p><p>To do so, we'll use the same function we used in <code>NewScreen</code> from Async Storage to get the items. To display the items, we'll use <a href=\"https://reactnative.dev/docs/flatlist\">FlatList</a>, a component that allows us to display a list of items easily.</p><p>Change the content of <code>HomeScreen</code> to the following:</p><pre><code class=\"language-js\">import { useAsyncStorage } from '@react-native-async-storage/async-storage';\nimport React, { useEffect, useState } from 'react';\nimport { FlatList, StyleSheet, Text, View } from 'react-native';\nimport { Card } from 'react-native-elements';\nimport Toast from 'react-native-toast-message';\n\nexport default function HomeScreen ({ navigation }) {\n  const { getItem } = useAsyncStorage('todo');\n  const [items, setItems] = useState([]);\n  const [loading, setLoading] = useState(true);\n\n  function getTodoList () {\n    getItem()\n      .then((todoJSON) =&gt; {\n        const todo = todoJSON ? JSON.parse(todoJSON) : [];\n        setItems(todo);\n        setLoading(false);\n      })\n      .catch((err) =&gt; {\n        console.error(err);\n        Toast.show({\n          type: 'error',\n          text1: 'An error occurred',\n          position: 'top'\n        });\n      });\n  }\n\n  function renderCard ({item}) {\n    return (\n      &lt;Card&gt;\n        &lt;Card.Title style={styles.cardTitle}&gt;{item.title}&lt;/Card.Title&gt;\n      &lt;/Card&gt;\n    )\n  }\n  \n  useEffect(() =&gt; {\n    const unsubscribe = navigation.addListener('focus', getTodoList);\n\n    return unsubscribe;\n  }, [])\n\n  return (\n    &lt;View&gt;\n      &lt;FlatList refreshing={loading} onRefresh={getTodoList} style={styles.list} data={items} \n        renderItem={renderCard} keyExtractor={(item) =&gt; item.id} /&gt;\n    &lt;/View&gt;\n  )\n}\n\nconst styles = StyleSheet.create({\n  list: {\n    width: '100%'\n  },\n  cardTitle: {\n    textAlign: 'left'\n  }\n})</code></pre><p>Here's a breakdown of what this code is doing. First, we're using <code>useAsyncStorage</code> hook just like we did before to get a getter function for <code>todo</code>. We're also creating state variables <code>items</code> and <code>loading</code>. <code>items</code> will be used to store the items after fetching them from the storage. <code>loading</code> will be used to indicate that we're currently retrieving the items from the storage.</p><p>Then, we create the function <code>getTodoList</code>. This function should be executed every time the screen is opened. In this function, we're just using the getter function <code>getItem</code> like we did before and once we retrieve the todo list items from the storage, we're setting the state <code>items</code> and <code>loading</code>.</p><p>After that, we create the function <code>renderCard</code>. This function will be used to render each item in the FlatList. We'll be using the <a href=\"https://reactnativeelements.com/docs/card\">Card</a> component from React Native Element to display them.</p><p>Next is the important part. In <code>useEffect</code>, we are adding an event listener to the <code>focus</code> event for the <code>navigator</code> object that the screens inside the navigation stack receive as a prop. The focus event is triggered every time the screen comes into focus. So, this listener for the focus event will run when the app launch and the Home screen is shown, and when we go back from the <code>NewScreen</code> to the Home screen.</p><p>Finally, we're displaying the <code>FlatList</code> component. It receives the <code>refreshing</code> prop which indicates whether the list is currently refreshing. We're passing it the <code>loading</code> state. We're also passing it an event handler for the refresh event in the prop <code>onRefresh</code>. This event is triggered whenever the user refreshes the list by pulling it down.</p><p>The <code>data</code> prop indicates the data that we're displaying in the list and should be an array. The <code>renderItem</code> prop receives a function to render each item, and that function will be passed an object which includes the <code>item</code> property, indicating the current item to be rendered in the list. </p><p>The <code>keyExtractor</code> prop indicates how to assign the <code>key</code> prop for each item in the list. In React and React Native, when rendering an array of items you should pass a key <code>prop</code> to each item. We're setting the key for each item its id.</p><p>In the end, we're defining the stylesheet to style all elements.</p><p> If you open the app now, you'll see that on the Home Screen a list of items will appear which are items that you add in the <code>NewScreen</code>. Try going to the <code>NewScreen</code> again and adding more items. You'll see them added to the list.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/09/IMG_7843.PNG\" class=\"kg-image\" alt loading=\"lazy\" width=\"1242\" height=\"2208\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/09/IMG_7843.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/09/IMG_7843.PNG 1000w, https://backend.shahednasser.com/content/images/2021/09/IMG_7843.PNG 1242w\" sizes=\"(min-width: 720px) 720px\"></figure><h2 id=\"publish-the-app\">Publish the App</h2><p>The last step that comes when creating an app is to publish it. React Native's documentation has a guide on how to publish your app on <a href=\"https://reactnative.dev/docs/signed-apk-android\">Google Play Store</a> and <a href=\"https://reactnative.dev/docs/publishing-to-app-store\">Apple App Store</a>.</p><p>If, however, you want to publish the app but you don't have a developer account for either Google or Apple, you can publish the <a href=\"https://docs.expo.dev/workflow/publishing/\">app on Expo</a>, but that would require anyone to install Expo to be able to try or use your app.</p><h2 id=\"conclusion\">Conclusion</h2><p>You just created your first app! You were able to create an app with navigation, forms, storage, lists, and more!</p><p>If you want to keep practicing, try adding a delete or edit functionality. Make sure to check more of React Native's <a href=\"https://reactnative.dev\">documentation</a> as well as React Navigation's documentation on <a href=\"https://reactnavigation.org/docs/params\">how to pass parameters</a> as well.</p>","url":"https://backend.shahednasser.com/react-native-tutorial-create-your-first-app/","canonical_url":null,"uuid":"ac72c285-6b4e-41a1-917f-65575fc6e18b","codeinjection_foot":null,"codeinjection_head":null,"codeinjection_styles":null,"comment_id":"614f6edf9d27d705cce79807","reading_time":18,"send_email_when_published":null,"email_subject":null,"childHtmlRehype":{"html":"<p><a href=\"https://reactnative.dev\">React Native</a> is one of the most popular frameworks that allow you to create cross-platform apps using JavaScript. Using React Native, you'll be able to write one code for the web, iOS, and Android.</p><p>In this tutorial, you'll learn the basics of creating a React Native app with <a href=\"https://expo.dev\">Expo</a>. We'll create a to-do list app where we'll learn about implementing navigation in a React Native app and storing data in our app.</p><p>You can find the code for this tutorial in <a href=\"https://github.com/shahednasser/react-native-tutorial\">this GitHub Repository</a>. You can also <a href=\"https://expo.dev/@shahednasser/todolist\">install the app</a> using Expo Go. There is more info on how to install Expo Go below.</p><h2 id=\"prerequisites\">Prerequisites</h2><p>Before you start going through the tutorial, you'll need to install <a href=\"https://nodejs.org/en/\">Node.js</a> which will install NPM with it.</p><p>You also need to install Expo. Expo provides a set of tools to make your mobile development with React Native easier. </p><p>To install Expo run:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">npm</span> <span class=\"token function\">install</span> -g expo-cli</code></pre></div><p>Finally, you'll need to install <a href=\"https://expo.dev/client\">Expo Go</a> on your phone. It's available for both <a href=\"https://play.google.com/store/apps/details?id=host.exp.exponent&#x26;hl=en&#x26;gl=US\">Android</a> and <a href=\"https://apps.apple.com/us/app/expo-go/id982107779\">iOS</a>.</p><p>By installing Expo Go on your phone, you'll be able to test your app directly on your phone as you make changes. </p><h2 id=\"setup-project\">Setup Project</h2><p>To create a new React Native project, run the following command in your terminal:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">expo init todolist</code></pre></div><p>You'll be asked to choose the kind of project you want to create, choose <code class=\"language-text\">blank</code>.</p><p>After you choose <code class=\"language-text\">blank</code>, the project will be set up and the minimal dependencies required to create an app with React Native will be installed.</p><p>After the setup is done, change to the directory of the project:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token builtin class-name\">cd</span> todolist</code></pre></div><h2 id=\"project-structure\">Project Structure</h2><p>Let's take a quick look at the project's structure before we start coding.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/09/Screen-Shot-2021-09-25-at-9.56.47-PM.png\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"548\" height=\"578\"></figure><p>We have the usual <code class=\"language-text\">package.json</code> files that you find in every NPM project.</p><p>There's <code class=\"language-text\">app.json</code>. This includes a set of configurations for our app. If you open it, you'll find key-value pairs related to the app name, version, icon, splash screen, and more.</p><p><code class=\"language-text\">App.js</code> is the entry point of our app. It's where we will start writing our app's code.</p><p>The <code class=\"language-text\">assets</code> directory includes images like the app icon, splash screen, and more.</p><h3 id=\"understand-first-components-in-react-native\">Understand First Components in React Native</h3><p>If you open <code class=\"language-text\">App.js</code>, you'll find content similar to this:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> StatusBar <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'expo-status-bar'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> React <span class=\"token keyword\">from</span> <span class=\"token string\">'react'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> StyleSheet<span class=\"token punctuation\">,</span> Text<span class=\"token punctuation\">,</span> View <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native'</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">export</span> <span class=\"token keyword\">default</span> <span class=\"token keyword\">function</span> <span class=\"token function\">App</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token keyword\">return</span> <span class=\"token punctuation\">(</span>\n    <span class=\"token operator\">&#x3C;</span>View style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>styles<span class=\"token punctuation\">.</span>container<span class=\"token punctuation\">}</span><span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span>Text<span class=\"token operator\">></span>Open up App<span class=\"token punctuation\">.</span>js to start working on your app<span class=\"token operator\">!</span><span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Text<span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span>StatusBar style<span class=\"token operator\">=</span><span class=\"token string\">\"auto\"</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n    <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>View<span class=\"token operator\">></span>\n  <span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span>\n\n<span class=\"token keyword\">const</span> styles <span class=\"token operator\">=</span> StyleSheet<span class=\"token punctuation\">.</span><span class=\"token function\">create</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\n  <span class=\"token literal-property property\">container</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token literal-property property\">flex</span><span class=\"token operator\">:</span> <span class=\"token number\">1</span><span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">backgroundColor</span><span class=\"token operator\">:</span> <span class=\"token string\">'#fff'</span><span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">alignItems</span><span class=\"token operator\">:</span> <span class=\"token string\">'center'</span><span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">justifyContent</span><span class=\"token operator\">:</span> <span class=\"token string\">'center'</span><span class=\"token punctuation\">,</span>\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n</code></pre></div><p>This is our first component! As you can see, components like <code class=\"language-text\">View</code>, <code class=\"language-text\">Text</code> and others imported from <code class=\"language-text\">react-native</code> are being used.</p><p>You should know that in React Native when displaying the text you need to do it inside a <code class=\"language-text\">Text</code> component. </p><p>React Native provides a set of components that will be later transformed into native components in iOS or Android.</p><p>We also create stylesheets to add styling to our components using <code class=\"language-text\">StyleSheet.create</code>, where <code class=\"language-text\">StyleSheet</code> is imported from <code class=\"language-text\">react-native</code> as well.</p><p>The <code class=\"language-text\">create</code> method takes an object of properties, which act like class names in CSS, and their values are objects of CSS-like properties and their values. Styling your components in React Native is almost identical to styling using CSS, with a few changes in some behaviors of some CSS properties.</p><h2 id=\"screens-and-navigation\">Screens and Navigation</h2><p>Now, we'll start adding screens to our app. To add different screens and manage navigation between them, we'll use <a href=\"https://reactnavigation.org/\">React Navigation</a>.</p><p>For an elaborate tutorial on Navigation, check out my tutorial <a href=\"https://blog.shahednasser.com/react-native-navigation-tutorial/\">React Native Navigation Tutorial</a>.</p><h3 id=\"home-screen\">Home Screen</h3><p>Create the directories <code class=\"language-text\">src/screens</code>. The <code class=\"language-text\">screens</code> directory will hold all the screens we will create later on.</p><p>Then, create <code class=\"language-text\">HomeScreen.js</code> inside <code class=\"language-text\">screens</code>. This will be the first screen that the user will see when they open the app.</p><p>Add the following content inside <code class=\"language-text\">HomeScreen.js</code>:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">import</span> React <span class=\"token keyword\">from</span> <span class=\"token string\">'react'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> Text<span class=\"token punctuation\">,</span> View <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native'</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">export</span> <span class=\"token keyword\">default</span> <span class=\"token keyword\">function</span> <span class=\"token function\">HomeScreen</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token keyword\">return</span> <span class=\"token punctuation\">(</span>\n    <span class=\"token operator\">&#x3C;</span>View<span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span>Text<span class=\"token operator\">></span>Welcome Home<span class=\"token operator\">!</span><span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Text<span class=\"token operator\">></span>\n    <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>View<span class=\"token operator\">></span>\n  <span class=\"token punctuation\">)</span>\n<span class=\"token punctuation\">}</span></code></pre></div><p>The home screen, at the moment, will just display the text \"Welcome Home!\".</p><h3 id=\"install-react-navigation\">Install React Navigation</h3><p>Next, we'll see how to use multiple screens with React Navigation.</p><p>React Navigation allows us to move between screens backward and forwards, add buttons to the header, and more.</p><p>To install React Navigation, run the following commands:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">npm</span> <span class=\"token function\">install</span> @react-navigation/native\nexpo <span class=\"token function\">install</span> react-native-screens react-native-safe-area-context\n<span class=\"token function\">npm</span> <span class=\"token function\">install</span> @react-navigation/native-stack</code></pre></div><p>Once these commands are done executing, we'll have all the dependencies required to use React Navigation.</p><h3 id=\"how-react-navigation-works\">How React Navigation Works</h3><p>To put things simply, React Navigation manages screens, navigation between them, and history as a Stack. </p><p>There's a default, initial screen that shows when the app is launched. Then, when you want to open a new screen, you can push it at the top of the stack or replace the current item in the stack.</p><p>Then, when you want to go backward, you pop the current item at the top of the stack and show the one below it, which was the previous screen, until you reach the home, initial screen.</p><p> If it sounds confusing at the moment, keep going through in the tutorial and you'll start understanding things more.</p><h3 id=\"create-the-navigation-stack\">Create the Navigation Stack</h3><p>Change the content of <code class=\"language-text\">App.js</code> to the following:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">import</span> <span class=\"token string\">'react-native-gesture-handler'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> React <span class=\"token keyword\">from</span> <span class=\"token string\">'react'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> createStackNavigator <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'@react-navigation/stack'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> NavigationContainer <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'@react-navigation/native'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> HomeScreen <span class=\"token keyword\">from</span> <span class=\"token string\">'./src/screens/HomeScreen'</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">const</span> Stack <span class=\"token operator\">=</span> <span class=\"token function\">createStackNavigator</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">export</span> <span class=\"token keyword\">default</span> <span class=\"token keyword\">function</span> <span class=\"token function\">App</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token keyword\">return</span> <span class=\"token punctuation\">(</span>\n    <span class=\"token operator\">&#x3C;</span>NavigationContainer<span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span>Stack<span class=\"token punctuation\">.</span>Navigator initialRouteName<span class=\"token operator\">=</span><span class=\"token string\">\"Home\"</span><span class=\"token operator\">></span>\n        <span class=\"token operator\">&#x3C;</span>Stack<span class=\"token punctuation\">.</span>Screen name<span class=\"token operator\">=</span><span class=\"token string\">\"Home\"</span> component<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>HomeScreen<span class=\"token punctuation\">}</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Stack<span class=\"token punctuation\">.</span>Navigator<span class=\"token operator\">></span>\n    <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>NavigationContainer<span class=\"token operator\">></span>\n  <span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span>\n</code></pre></div><p>Let's go over things bit by bit.</p><p>We first need to import <code class=\"language-text\">react-native-gesture-handler</code> at the top of the app. This allows navigating using gestures. The higher in the app it's placed the better.</p><p>Next, we're importing <code class=\"language-text\">createStackNavigator</code>. This function returns a Stack object, which contains two components <code class=\"language-text\">Screen</code> and <code class=\"language-text\">Navigator</code>. </p><p><code class=\"language-text\">Screen</code> is used to display screen components that we create, define their options, and more. If you look at the example above, we provide a <code class=\"language-text\">name</code> and <code class=\"language-text\">component</code> props for a screen:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token operator\">&#x3C;</span>Stack<span class=\"token punctuation\">.</span>Screen name<span class=\"token operator\">=</span><span class=\"token string\">\"Home\"</span> component<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>HomeScreen<span class=\"token punctuation\">}</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span></code></pre></div><p>The <code class=\"language-text\">name</code> prop can be used to navigate to that screen at any given point later. The <code class=\"language-text\">component</code> prop will be used to define the screen component to render when the screen is navigated to.</p><p><code class=\"language-text\">Navigator</code> should contain <code class=\"language-text\">Screen</code> components as children as it manages the routing between them. <code class=\"language-text\">Navigator</code> also receives the <code class=\"language-text\">initialRouteName</code> prop which determines the screen that should open when the app first launches.</p><p>Finally, we use <code class=\"language-text\">NavigationContainer</code> to wrap the <code class=\"language-text\">Navigator</code> components, as it manages the navigation tree and state.</p><p>So, in <code class=\"language-text\">App.js</code>, which will contain the navigation routes for the screens in the app as we go forward, we should render the <code class=\"language-text\">NavigationContainer</code> and inside it <code class=\"language-text\">Stack.Navigator</code> which contains one or more <code class=\"language-text\">Stack.Screen</code> components:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token operator\">&#x3C;</span>NavigationContainer<span class=\"token operator\">></span>\n    <span class=\"token operator\">&#x3C;</span>Stack<span class=\"token punctuation\">.</span>Navigator initialRouteName<span class=\"token operator\">=</span><span class=\"token string\">\"Home\"</span><span class=\"token operator\">></span>\n        <span class=\"token operator\">&#x3C;</span>Stack<span class=\"token punctuation\">.</span>Screen name<span class=\"token operator\">=</span><span class=\"token string\">\"Home\"</span> component<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>HomeScreen<span class=\"token punctuation\">}</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n    <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Stack<span class=\"token punctuation\">.</span>Navigator<span class=\"token operator\">></span>\n<span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>NavigationContainer<span class=\"token operator\">></span></code></pre></div><h2 id=\"run-the-app\">Run the App</h2><p>Let's run the app now. To do that, open the terminal and run the following:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">npm</span> start</code></pre></div><p>This will start Expo. As mentioned earlier, with Expo you will be able to run the app on your phone, so make sure you've installed Expo Go as detailed in the Prerequisites section.</p><p>A web page will open that looks something like this:</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/09/Screen-Shot-2021-09-26-at-3.16.27-PM.png\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"2000\" height=\"1172\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/09/Screen-Shot-2021-09-26-at-3.16.27-PM.png 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/09/Screen-Shot-2021-09-26-at-3.16.27-PM.png 1000w, https://backend.shahednasser.com/content/images/size/w1600/2021/09/Screen-Shot-2021-09-26-at-3.16.27-PM.png 1600w, https://backend.shahednasser.com/content/images/size/w2400/2021/09/Screen-Shot-2021-09-26-at-3.16.27-PM.png 2400w\" sizes=\"(min-width: 720px) 720px\"></figure><p>There are multiple ways to run the app after this on your device. You can scan the QR code with your phone to open it in Expo Go. Alternatively, you can use one of the actions on the sidebar of the web page above like send link with email and so on.</p><p>Once you choose the best way to open the app on your phone and it opens, you should see the following screen:</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/09/IMG_7813.PNG\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"1242\" height=\"2208\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/09/IMG_7813.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/09/IMG_7813.PNG 1000w, https://backend.shahednasser.com/content/images/2021/09/IMG_7813.PNG 1242w\" sizes=\"(min-width: 720px) 720px\"></figure><p>We've run our first app! We'll start customizing the styles of the header next and add more screens to create a Todo List app.</p><h2 id=\"style-the-header\">Style the Header</h2><p>With React Navigation, there are 2 ways to style the header of a screen.</p><h3 id=\"style-screen-headers-individually\">Style Screen Headers Individually</h3><p>The first way is to style it for each screen. This can be done by passing the <code class=\"language-text\">options</code> prop to a <code class=\"language-text\">Screen</code> component like this:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token operator\">&#x3C;</span>Stack<span class=\"token punctuation\">.</span>Screen \n    name<span class=\"token operator\">=</span><span class=\"token string\">\"Home\"</span> \n    component<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>HomeScreen<span class=\"token punctuation\">}</span> \n    options<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">{</span>\n\t\t<span class=\"token literal-property property\">headerStyle</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n\t\t\t<span class=\"token literal-property property\">backgroundColor</span><span class=\"token operator\">:</span> <span class=\"token string\">'#228CDB'</span>\n\t\t<span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n        <span class=\"token literal-property property\">headerTintColor</span><span class=\"token operator\">:</span> <span class=\"token string\">'#fff'</span>\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">}</span> \n<span class=\"token operator\">/</span><span class=\"token operator\">></span></code></pre></div><p>The <code class=\"language-text\">options</code> prop is an object of options for the screen. To style the header, we can use the following three properties:</p><ol><li><code class=\"language-text\">headerStyle</code>: accepts an object of styles to apply to the header. To set the background color of the header, we pass it the <code class=\"language-text\">backgroundColor</code> prop with the value of the background color of the header.</li><li><code class=\"language-text\">headerTintColor</code>: the color of the text or buttons that are in the header.</li><li><code class=\"language-text\">headerTitleStyle</code>: accepts an object of font-related styles to make changes to the title in the header. For example, we can change the <code class=\"language-text\">fontFamily</code> or <code class=\"language-text\">fontWeight</code>.</li></ol><p>Using this prop, we'll be able to style the header of a screen.</p><h3 id=\"style-all-screen-headers\">Style All Screen Headers</h3><p>In general cases, styling each screen separately is tedious and leads to repeated code. Usually, you'd apply the same header style to all screens in the app.</p><p>In this case, we can use the <code class=\"language-text\">screenOptions</code> prop on the <code class=\"language-text\">Navigator</code> component. This prop accepts the same header options as the <code class=\"language-text\">options</code> prop in the <code class=\"language-text\">Screen</code> component and applies the styling to all screens.</p><h3 id=\"apply-header-styles-in-our-app\">Apply Header Styles in Our App</h3><p>In our app, we'll apply the same header style to all the screens in the app. So, we'll use the second way to style a header.</p><p>In App.js, replace this line:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token operator\">&#x3C;</span>Stack<span class=\"token punctuation\">.</span>Navigator initialRouteName<span class=\"token operator\">=</span><span class=\"token string\">\"Home\"</span><span class=\"token operator\">></span></code></pre></div><p>With the following:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token operator\">&#x3C;</span>Stack<span class=\"token punctuation\">.</span>Navigator\n    screenOptions<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">{</span>\n\t\t\t<span class=\"token literal-property property\">headerStyle</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n\t\t\t\t<span class=\"token literal-property property\">backgroundColor</span><span class=\"token operator\">:</span> <span class=\"token string\">'#228CDB'</span>\n\t\t\t<span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n        \t<span class=\"token literal-property property\">headerTintColor</span><span class=\"token operator\">:</span> <span class=\"token string\">'#fff'</span>\n    \t<span class=\"token punctuation\">}</span><span class=\"token punctuation\">}</span> \n    initialRouteName<span class=\"token operator\">=</span><span class=\"token string\">\"Home\"</span><span class=\"token operator\">></span></code></pre></div><p>This will change the background color of the header to <code class=\"language-text\">#228CDB</code> and the color of the text and buttons in the header to <code class=\"language-text\">#fff</code>.</p><p>If you save the changes and open the app again, you'll see that the header color changed.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/09/IMG_7814.PNG\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"1242\" height=\"2208\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/09/IMG_7814.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/09/IMG_7814.PNG 1000w, https://backend.shahednasser.com/content/images/2021/09/IMG_7814.PNG 1242w\" sizes=\"(min-width: 720px) 720px\"></figure><h2 id=\"navigate-screens\">Navigate Screens</h2><p>Next, we'll see how to add another screen and navigate to it. We'll also see how to add a header button.</p><h3 id=\"add-new-screen\">Add New Screen</h3><p>We'll add a new screen, which we'll use later to add a new to-do list item. </p><p>Create <code class=\"language-text\">src/screens/NewScreen.js</code> with the following content:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">import</span> React <span class=\"token keyword\">from</span> <span class=\"token string\">'react'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> Text<span class=\"token punctuation\">,</span> View <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native'</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">export</span> <span class=\"token keyword\">default</span> <span class=\"token keyword\">function</span> <span class=\"token function\">NewScreen</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token keyword\">return</span> <span class=\"token punctuation\">(</span>\n    <span class=\"token operator\">&#x3C;</span>View<span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span>Text<span class=\"token operator\">></span>This is New Screen<span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Text<span class=\"token operator\">></span>\n    <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>View<span class=\"token operator\">></span>\n  <span class=\"token punctuation\">)</span>\n<span class=\"token punctuation\">}</span></code></pre></div><p>Similar to <code class=\"language-text\">HomeScreen</code>, we're just showing the text \"This is New Screen\" for now.</p><h3 id=\"add-route-for-new-screen\">Add Route for New Screen</h3><p>Now, we need to add a new route in our navigation stack for the new route. In <code class=\"language-text\">App.js</code> below the <code class=\"language-text\">Screen</code> component for <code class=\"language-text\">HomeScreen</code> add a new one for <code class=\"language-text\">NewScreen</code>:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token operator\">&#x3C;</span>Stack<span class=\"token punctuation\">.</span>Screen name<span class=\"token operator\">=</span><span class=\"token string\">\"New\"</span> component<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>NewScreen<span class=\"token punctuation\">}</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span></code></pre></div><h3 id=\"add-header-button\">Add Header Button</h3><p>Next, we'll add a header button on the Home screen. It will be a plus button that should take us to <code class=\"language-text\">NewScreen</code>.</p><p>To add a button to the header of a screen, we do it using the <code class=\"language-text\">headerRight</code> property of the <code class=\"language-text\">options</code> prop passed to <code class=\"language-text\">Screen</code>. The <code class=\"language-text\">headerRight</code> property accepts a function that should return a component to render.</p><p>Instead of using React Native's <a href=\"https://reactnative.dev/docs/button\">Button</a> component, we'll use <a href=\"https://reactnativeelements.com\">React Native Elements</a>' <a href=\"https://reactnativeelements.com/docs/icon\">Icon</a> component. Adding a plus icon looks better than an actual button.</p><p>So, let's first install React Native Elements in our project:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">npm</span> i react-native-elements</code></pre></div><p>Then, change the following line in <code class=\"language-text\">App.js</code>:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token operator\">&#x3C;</span>Stack<span class=\"token punctuation\">.</span>Screen name<span class=\"token operator\">=</span><span class=\"token string\">\"Home\"</span> component<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>HomeScreen<span class=\"token punctuation\">}</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span></code></pre></div><p>to this:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token operator\">&#x3C;</span>Stack<span class=\"token punctuation\">.</span>Screen \n    name<span class=\"token operator\">=</span><span class=\"token string\">\"Home\"</span> \n    component<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>HomeScreen<span class=\"token punctuation\">}</span> \n    options<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">{</span>\n         <span class=\"token function-variable function\">headerRight</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">(</span>\n             <span class=\"token operator\">&#x3C;</span>Icon \n             name<span class=\"token operator\">=</span><span class=\"token string\">\"plus\"</span> \n             type<span class=\"token operator\">=</span><span class=\"token string\">\"feather\"</span> \n             color<span class=\"token operator\">=</span><span class=\"token string\">\"#fff\"</span>\n             style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>style<span class=\"token punctuation\">.</span>headerIcon<span class=\"token punctuation\">}</span>\n         <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n    <span class=\"token punctuation\">)</span>\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">}</span>\n<span class=\"token operator\">/</span><span class=\"token operator\">></span></code></pre></div><p>As you can see, we are using the Icon component, passing it the prop <code class=\"language-text\">name</code> which is the name of the icon to be used. <code class=\"language-text\">type</code> as React Native Elements allow us to choose from multiple icon sets. We are using <a href=\"https://feathericons.com\">Feather</a> icons. <code class=\"language-text\">color</code> indicates the color of the icon. And finally, we're passing it <code class=\"language-text\">style</code>. Add the following to the end of <code class=\"language-text\">App.js</code> to create a new stylesheet:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">const</span> style <span class=\"token operator\">=</span> StyleSheet<span class=\"token punctuation\">.</span><span class=\"token function\">create</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\n  <span class=\"token literal-property property\">headerIcon</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token literal-property property\">marginRight</span><span class=\"token operator\">:</span> <span class=\"token number\">10</span>\n  <span class=\"token punctuation\">}</span>\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div><p>This will add a margin-right to the icon, as it won't have any by default.</p><p>If you run the app now, you'll see that a new + icon has been added to the header but it does nothing at the moment.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/09/IMG_7817.PNG\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"1242\" height=\"2208\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/09/IMG_7817.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/09/IMG_7817.PNG 1000w, https://backend.shahednasser.com/content/images/2021/09/IMG_7817.PNG 1242w\" sizes=\"(min-width: 720px) 720px\"></figure><h3 id=\"navigating-to-another-screen\">Navigating to Another Screen</h3><p>We need to navigate to <code class=\"language-text\">NewScreen</code> when the plus icon is pressed.</p><p>In React Native, button's press events are handled by passing a listener in the <code class=\"language-text\">onPress</code> prop of the button. So, we'll need to pass a handler for <code class=\"language-text\">onPress</code> to <code class=\"language-text\">Icon</code>.</p><p>To navigate to another screen, we can use the <code class=\"language-text\">navigation</code> prop. The <code class=\"language-text\">navigation</code> prop is passed to every screen in the stack navigation. </p><p>Another way we can use the <code class=\"language-text\">navigation</code> prop is by changing the value that the <code class=\"language-text\">options</code> prop accepts of a <code class=\"language-text\">Screen</code> to a function. The function accepts as a parameter an object which contains <code class=\"language-text\">navigation</code>, and the function should return an object of options.</p><p>Then, using the <code class=\"language-text\">navigation</code> prop we can navigate to another screen with the <code class=\"language-text\">navigate</code> method:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\">navigation<span class=\"token punctuation\">.</span><span class=\"token function\">navigate</span><span class=\"token punctuation\">(</span><span class=\"token string\">'New'</span><span class=\"token punctuation\">)</span></code></pre></div><p>Where <code class=\"language-text\">navigate</code> accepts the name of the screen we're navigating to.</p><p>So, change the line for <code class=\"language-text\">HomeScreen</code> in <code class=\"language-text\">App.js</code> to the following:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token operator\">&#x3C;</span>Stack<span class=\"token punctuation\">.</span>Screen \n    name<span class=\"token operator\">=</span><span class=\"token string\">\"Home\"</span> \n    component<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>HomeScreen<span class=\"token punctuation\">}</span> \n    options<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">(</span><span class=\"token parameter\"><span class=\"token punctuation\">{</span>navigation<span class=\"token punctuation\">}</span></span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\n        <span class=\"token function-variable function\">headerRight</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">(</span>\n            <span class=\"token operator\">&#x3C;</span>Icon \n            name<span class=\"token operator\">=</span><span class=\"token string\">\"plus\"</span> \n            type<span class=\"token operator\">=</span><span class=\"token string\">\"feather\"</span> \n            color<span class=\"token operator\">=</span><span class=\"token string\">\"#fff\"</span>\n            style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>style<span class=\"token punctuation\">.</span>headerIcon<span class=\"token punctuation\">}</span>\n                                onPress<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> navigation<span class=\"token punctuation\">.</span><span class=\"token function\">navigate</span><span class=\"token punctuation\">(</span><span class=\"token string\">'New'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">}</span>\n    \t\t<span class=\"token operator\">/</span><span class=\"token operator\">></span>\n    \t<span class=\"token punctuation\">)</span>\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">}</span>\n<span class=\"token operator\">/</span><span class=\"token operator\">></span></code></pre></div><p>If you open the app now and click on the plus icon, you'll be taken to <code class=\"language-text\">NewScreen</code>.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/09/IMG_7818.PNG\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"1242\" height=\"2208\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/09/IMG_7818.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/09/IMG_7818.PNG 1000w, https://backend.shahednasser.com/content/images/2021/09/IMG_7818.PNG 1242w\" sizes=\"(min-width: 720px) 720px\"></figure><p>You can also see that, by default, a back button is added to the header and you can use it to go backward in the navigation stack. If you click on it, you'll go back to the Home screen.</p><h2 id=\"new-todo-item-form\">New Todo Item Form</h2><p>Next, we'll add a form to add a new todo item in <code class=\"language-text\">NewScreen</code>. To simplify creating a form, we'll use <a href=\"https://formik.org\">Formik</a>.</p><p>If you're not familiar with Formik, it's a React and React Native library that aims to simplify the process of creating a form.</p><p>To install Formik, run the following command:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">npm</span> <span class=\"token function\">install</span> formik --save</code></pre></div><p>Then, change the content of <code class=\"language-text\">src/screens/NewScreen.js</code> to the following:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> Formik <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'formik'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> React <span class=\"token keyword\">from</span> <span class=\"token string\">'react'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> StyleSheet<span class=\"token punctuation\">,</span> View <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> Text <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native-elements'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> Button <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native-elements/dist/buttons/Button'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> Input <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native-elements/dist/input/Input'</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">export</span> <span class=\"token keyword\">default</span> <span class=\"token keyword\">function</span> <span class=\"token function\">NewScreen</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n\n  <span class=\"token keyword\">function</span> <span class=\"token function\">newTask</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\">values</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n\t<span class=\"token comment\">//TODO save new task</span>\n  <span class=\"token punctuation\">}</span>\n\n  <span class=\"token keyword\">return</span> <span class=\"token punctuation\">(</span>\n    <span class=\"token operator\">&#x3C;</span>Formik\n      initialValues<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">{</span><span class=\"token literal-property property\">title</span><span class=\"token operator\">:</span> <span class=\"token string\">''</span><span class=\"token punctuation\">}</span><span class=\"token punctuation\">}</span>\n      onSubmit<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>newTask<span class=\"token punctuation\">}</span>\n    <span class=\"token operator\">></span>\n      <span class=\"token punctuation\">{</span><span class=\"token punctuation\">(</span><span class=\"token parameter\"><span class=\"token punctuation\">{</span>handleChange<span class=\"token punctuation\">,</span> handleBlur<span class=\"token punctuation\">,</span> handleSubmit<span class=\"token punctuation\">,</span> values<span class=\"token punctuation\">}</span></span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">(</span>\n        <span class=\"token operator\">&#x3C;</span>View style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>style<span class=\"token punctuation\">.</span>container<span class=\"token punctuation\">}</span><span class=\"token operator\">></span>\n          <span class=\"token operator\">&#x3C;</span>Text h4<span class=\"token operator\">></span>New Todo Item<span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Text<span class=\"token operator\">></span>\n          <span class=\"token operator\">&#x3C;</span>Input \n            placeholder<span class=\"token operator\">=</span><span class=\"token string\">\"Example: Cook, Clean, etc...\"</span> \n            onChangeText<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token function\">handleChange</span><span class=\"token punctuation\">(</span><span class=\"token string\">'title'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">}</span>\n            onBlur<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token function\">handleBlur</span><span class=\"token punctuation\">(</span><span class=\"token string\">'title'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">}</span>\n            style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>style<span class=\"token punctuation\">.</span>input<span class=\"token punctuation\">}</span>\n          <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n          <span class=\"token operator\">&#x3C;</span>Button title<span class=\"token operator\">=</span><span class=\"token string\">\"Add\"</span> onPress<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>handleSubmit<span class=\"token punctuation\">}</span> style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>style<span class=\"token punctuation\">.</span>button<span class=\"token punctuation\">}</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n        <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>View<span class=\"token operator\">></span>\n      <span class=\"token punctuation\">)</span><span class=\"token punctuation\">}</span>\n    <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Formik<span class=\"token operator\">></span>\n  <span class=\"token punctuation\">)</span>\n<span class=\"token punctuation\">}</span>\n\n<span class=\"token keyword\">const</span> style <span class=\"token operator\">=</span> StyleSheet<span class=\"token punctuation\">.</span><span class=\"token function\">create</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\n  <span class=\"token literal-property property\">container</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token literal-property property\">marginTop</span><span class=\"token operator\">:</span> <span class=\"token number\">10</span><span class=\"token punctuation\">,</span>\n    <span class=\"token literal-property property\">padding</span><span class=\"token operator\">:</span> <span class=\"token number\">10</span>\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n  <span class=\"token literal-property property\">input</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token literal-property property\">marginTop</span><span class=\"token operator\">:</span> <span class=\"token number\">10</span>\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n  <span class=\"token literal-property property\">button</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token literal-property property\">backgroundColor</span><span class=\"token operator\">:</span> <span class=\"token string\">'#228CDB'</span>\n  <span class=\"token punctuation\">}</span>\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span></code></pre></div><p>Let's go over everything we just added. We first define a new function <code class=\"language-text\">newTask</code> inside the component, which we'll use later to handle saving a new task.</p><p>Then, we're creating a form with Formik. In Formik, you can use the <code class=\"language-text\">Formik</code> component and pass it <code class=\"language-text\">initialValues</code> to define the fields and their initial values. We just have one field <code class=\"language-text\">title</code> and its initial value is just an empty string.</p><p>We also pass the <code class=\"language-text\">Formik</code> component an <code class=\"language-text\">onSubmit</code> prop which is the function that should be executed when the form is submitted. We're passing it <code class=\"language-text\">newTask</code>.</p><p>Inside the <code class=\"language-text\">Formik</code> component, you use a function that has a set of parameters but most importantly are <code class=\"language-text\">handleChange</code>, <code class=\"language-text\">handleBlur</code>, <code class=\"language-text\">handleSubmit</code>, and <code class=\"language-text\">values</code>. The function should return a component to render.</p><p>If you're familiar with Formik when using it with React, you'll notice that this is slightly different than how you'd use it with React. As inputs in React Native are not similar to inputs on the web since they don't have names, you need to clearly specify for each input the <code class=\"language-text\">onChange</code> and <code class=\"language-text\">onBlur</code> listeners passing them the name of the input.</p><p>So, for the title <a href=\"https://reactnativeelements.com/docs/input\">Input</a>, which is a component we are using from React Native Elements, we pass for <code class=\"language-text\">onChange</code> the listener <code class=\"language-text\">handleChange('title')</code> and for <code class=\"language-text\">onBlur</code> the listener <code class=\"language-text\">handleBlur('title')</code>.</p><p>Then, we add a <a href=\"https://reactnativeelements.com/docs/button\">Button</a> component, which is another component we are using from React Native Elements. We assign the listener for <code class=\"language-text\">onPress</code> on the button to <code class=\"language-text\">handleSubmit</code>. This means that when the button is pressed, the submit event will be triggered in the form, which will trigger <code class=\"language-text\">newTask</code> since we assigned it as the listener to <code class=\"language-text\">onSubmit</code>.</p><p>Notice that we are adding some styling to the screen and components in it. We use the <code class=\"language-text\">styles</code> variable which is created with <code class=\"language-text\">StyleSheet.create</code>, and we pass to each component a style prop with its value a property in the <code class=\"language-text\">styles</code> variable. For example in <code class=\"language-text\">View</code>:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token operator\">&#x3C;</span>View style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>style<span class=\"token punctuation\">.</span>container<span class=\"token punctuation\">}</span><span class=\"token operator\">></span></code></pre></div><p>If you open the app now, click on the plus button in the Home Screen which will open <code class=\"language-text\">NewScreen</code>. You should see the form we just created.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/09/IMG_7819.PNG\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"1242\" height=\"2208\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/09/IMG_7819.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/09/IMG_7819.PNG 1000w, https://backend.shahednasser.com/content/images/2021/09/IMG_7819.PNG 1242w\" sizes=\"(min-width: 720px) 720px\"></figure><h3 id=\"handle-submit\">Handle Submit</h3><p>We'll now handle the submission of the form in the function <code class=\"language-text\">newTask</code>. What we'll do is take the title and store it in the app.</p><p>There are many ways you can manage storage in React Native. We'll use <a href=\"https://react-native-async-storage.github.io/async-storage/\">Async Storage</a>. It provides a simple API to store data in your app. For data that are not too complex, like settings related to the user or app, it's a great choice.</p><p>We'll use Async Storage to store the todo list items in our app. So, let's first install it:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">expo <span class=\"token function\">install</span> @react-native-async-storage/async-storage</code></pre></div><p>AsyncStorage has 2 functions in its API. getItem and setItem. using setItem, you set items serialized as strings. So, if you have an array or object you need to stringify them with <code class=\"language-text\">JSON.stringify</code>. Then, you can retrieve the item with <code class=\"language-text\">getItem</code> and you'll have to parse the JSON if it's stringified with <code class=\"language-text\">JSON.parse</code>.</p><p>Add the following import at the beginning of <code class=\"language-text\">NewScreen.js</code> along with the rest of the imports added before:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> useAsyncStorage <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'@react-native-async-storage/async-storage'</span><span class=\"token punctuation\">;</span></code></pre></div><p>Then, inside the <code class=\"language-text\">NewScreen</code> component, add the following line:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">const</span> <span class=\"token punctuation\">{</span> getItem<span class=\"token punctuation\">,</span> setItem <span class=\"token punctuation\">}</span> <span class=\"token operator\">=</span> <span class=\"token function\">useAsyncStorage</span><span class=\"token punctuation\">(</span><span class=\"token string\">'todo'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div><p>We are using the <a href=\"https://react-native-async-storage.github.io/async-storage/docs/api#useasyncstorage\">useAsyncStorage</a> hook which allows us to pass the name of a key in the storage and retrieve a getter <code class=\"language-text\">getItem</code> and a setter <code class=\"language-text\">setItem</code> solely for that key in the storage.</p><p>Before we start implementing the functionality inside <code class=\"language-text\">newTask</code>, we need 2 other dependencies: <a href=\"https://www.npmjs.com/package/react-native-uuid\">react-native-uuid</a> to generate random IDs for every task in storage, and <a href=\"https://www.npmjs.com/package/react-native-toast-message\">react-native-toast-message</a> to show toast messages if an error occurs:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">npm</span> i react-native-uuid react-native-toast-message</code></pre></div><p>For react-native-toast-message to work, we first need to add a <code class=\"language-text\">Toast</code> component in one of the higher components rendered in the App. So, add the following line in <code class=\"language-text\">App.js</code> before the closing of <code class=\"language-text\">NavigationContainer</code>:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\">\t<span class=\"token operator\">&#x3C;</span>Toast ref<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">ref</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> Toast<span class=\"token punctuation\">.</span><span class=\"token function\">setRef</span><span class=\"token punctuation\">(</span>ref<span class=\"token punctuation\">)</span><span class=\"token punctuation\">}</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n<span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>NavigationContainer<span class=\"token operator\">></span></code></pre></div><p>And, of course, add the necessary import at the beginning of <code class=\"language-text\">App.js</code>:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">import</span> Toast <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native-toast-message'</span><span class=\"token punctuation\">;</span></code></pre></div><p>Back to <code class=\"language-text\">NewScreen.js</code>. We'll now implement <code class=\"language-text\">newTask</code>. We'll first validate that the user entered a value for <code class=\"language-text\">title</code>. Then, we'll get the <code class=\"language-text\">todo</code> items from the storage, which will be an array of objects where each object is a to-do item. Then, we'll push a new item into the array and set the item in storage again.</p><p>Change the <code class=\"language-text\">newTask</code> function to the following:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">function</span> <span class=\"token function\">newTask</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\">values</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span><span class=\"token operator\">!</span>values<span class=\"token punctuation\">.</span>title<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n      Toast<span class=\"token punctuation\">.</span><span class=\"token function\">show</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\n        <span class=\"token literal-property property\">type</span><span class=\"token operator\">:</span> <span class=\"token string\">'error'</span><span class=\"token punctuation\">,</span>\n        <span class=\"token literal-property property\">text1</span><span class=\"token operator\">:</span> <span class=\"token string\">'Title is required'</span><span class=\"token punctuation\">,</span>\n        <span class=\"token literal-property property\">position</span><span class=\"token operator\">:</span> <span class=\"token string\">'top'</span>\n      <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n      <span class=\"token keyword\">return</span><span class=\"token punctuation\">;</span>\n    <span class=\"token punctuation\">}</span>\n    <span class=\"token comment\">//get todo array from storage</span>\n    <span class=\"token function\">getItem</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span>\n      <span class=\"token punctuation\">.</span><span class=\"token function\">then</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">todoJSON</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\n        <span class=\"token keyword\">let</span> todo <span class=\"token operator\">=</span> todoJSON <span class=\"token operator\">?</span> <span class=\"token constant\">JSON</span><span class=\"token punctuation\">.</span><span class=\"token function\">parse</span><span class=\"token punctuation\">(</span>todoJSON<span class=\"token punctuation\">)</span> <span class=\"token operator\">:</span> <span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">;</span>\n        <span class=\"token comment\">//add a new item to the list</span>\n        todo<span class=\"token punctuation\">.</span><span class=\"token function\">push</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\n          <span class=\"token literal-property property\">id</span><span class=\"token operator\">:</span> uuid<span class=\"token punctuation\">.</span><span class=\"token function\">v4</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span>\n          <span class=\"token literal-property property\">title</span><span class=\"token operator\">:</span> values<span class=\"token punctuation\">.</span>title\n        <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n        <span class=\"token comment\">//set item in storage again</span>\n        <span class=\"token function\">setItem</span><span class=\"token punctuation\">(</span><span class=\"token constant\">JSON</span><span class=\"token punctuation\">.</span><span class=\"token function\">stringify</span><span class=\"token punctuation\">(</span>todo<span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span>\n          <span class=\"token punctuation\">.</span><span class=\"token function\">then</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\n            <span class=\"token comment\">//navigate back to home screen</span>\n            navigation<span class=\"token punctuation\">.</span><span class=\"token function\">goBack</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n          <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">catch</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">err</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\n            console<span class=\"token punctuation\">.</span><span class=\"token function\">error</span><span class=\"token punctuation\">(</span>err<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n            Toast<span class=\"token punctuation\">.</span><span class=\"token function\">show</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\n              <span class=\"token literal-property property\">type</span><span class=\"token operator\">:</span> <span class=\"token string\">'error'</span><span class=\"token punctuation\">,</span>\n              <span class=\"token literal-property property\">text1</span><span class=\"token operator\">:</span> <span class=\"token string\">'An error occurred and a new item could not be saved'</span><span class=\"token punctuation\">,</span>\n              <span class=\"token literal-property property\">position</span><span class=\"token operator\">:</span> <span class=\"token string\">'top'</span>\n            <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n          <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n      <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span>\n      <span class=\"token punctuation\">.</span><span class=\"token function\">catch</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">err</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\n        console<span class=\"token punctuation\">.</span><span class=\"token function\">error</span><span class=\"token punctuation\">(</span>err<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n        Toast<span class=\"token punctuation\">.</span><span class=\"token function\">show</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\n          <span class=\"token literal-property property\">type</span><span class=\"token operator\">:</span> <span class=\"token string\">'error'</span><span class=\"token punctuation\">,</span>\n          <span class=\"token literal-property property\">text1</span><span class=\"token operator\">:</span> <span class=\"token string\">'An error occurred and a new item could not be saved'</span><span class=\"token punctuation\">,</span>\n          <span class=\"token literal-property property\">position</span><span class=\"token operator\">:</span> <span class=\"token string\">'bottom'</span>\n        <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n      <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token punctuation\">}</span></code></pre></div><p>As you can see, we're checking first if <code class=\"language-text\">values.title</code> has been entered. If not, we show a toast message and return. To show a toast message using react-native-toast-message you need to pass it an object of options. There are a variety of options you can use, but the most important here are <code class=\"language-text\">type</code> which can be <code class=\"language-text\">error</code>, <code class=\"language-text\">success</code>, or <code class=\"language-text\">info</code>, <code class=\"language-text\">position</code> which can be <code class=\"language-text\">top</code> or <code class=\"language-text\">bottom</code>, and <code class=\"language-text\">text1</code> which will be the message to show in the toast.</p><p>After validating <code class=\"language-text\">title</code>, we then use <code class=\"language-text\">getItem</code> to retrieve <code class=\"language-text\">todo</code> from the storage if it exists. <code class=\"language-text\">getItem</code> returns a Promise as it is asynchronous, and the value of <code class=\"language-text\">todo</code> is passed to <code class=\"language-text\">then</code> function handler.</p><p>Inside <code class=\"language-text\">then</code> we parse the JSON, then push a new to-do item. Each todo item will have an <code class=\"language-text\">id</code> which is randomly generated, and a <code class=\"language-text\">title</code>.</p><p>Finally, we set the <code class=\"language-text\">todo</code> array in the storage again as JSON. Once it is set successfully, we navigate back to the Home screen with <code class=\"language-text\">navigation.goBack</code>. As we mentioned earlier, all items in the navigation stack receive <code class=\"language-text\">navigation</code> as a prop. So, make sure to add the prop for <code class=\"language-text\">NewScreen</code>:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">export</span> <span class=\"token keyword\">default</span> <span class=\"token keyword\">function</span> <span class=\"token function\">NewScreen</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\"><span class=\"token punctuation\">{</span> navigation <span class=\"token punctuation\">}</span></span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span></code></pre></div><p>You can now try the form. Open the app and go to the <code class=\"language-text\">NewScreen</code>. Try first to submit the form without entering a title. You should see then a message telling you that the Title is required.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/09/IMG_7841.PNG\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"1242\" height=\"2208\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/09/IMG_7841.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/09/IMG_7841.PNG 1000w, https://backend.shahednasser.com/content/images/2021/09/IMG_7841.PNG 1242w\" sizes=\"(min-width: 720px) 720px\"></figure><p>Now try to enter a title and press \"Add\". You'll be navigated back to the Home Screen. That means that the item was added successfully!</p><p>What's left for us to do is display them on the Home Screen.</p><h3 id=\"display-tasks\">Display Tasks</h3><p>We'll now change the content of the Home Screen to display the todo list items we are adding in <code class=\"language-text\">NewScreen</code>.</p><p>To do so, we'll use the same function we used in <code class=\"language-text\">NewScreen</code> from Async Storage to get the items. To display the items, we'll use <a href=\"https://reactnative.dev/docs/flatlist\">FlatList</a>, a component that allows us to display a list of items easily.</p><p>Change the content of <code class=\"language-text\">HomeScreen</code> to the following:</p><div class=\"kg-card kg-code-card gatsby-highlight\" data-language=\"js\"><pre class=\"language-js\"><code class=\"language-js\"><span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> useAsyncStorage <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'@react-native-async-storage/async-storage'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> React<span class=\"token punctuation\">,</span> <span class=\"token punctuation\">{</span> useEffect<span class=\"token punctuation\">,</span> useState <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> FlatList<span class=\"token punctuation\">,</span> StyleSheet<span class=\"token punctuation\">,</span> Text<span class=\"token punctuation\">,</span> View <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> Card <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native-elements'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">import</span> Toast <span class=\"token keyword\">from</span> <span class=\"token string\">'react-native-toast-message'</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">export</span> <span class=\"token keyword\">default</span> <span class=\"token keyword\">function</span> <span class=\"token function\">HomeScreen</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\"><span class=\"token punctuation\">{</span> navigation <span class=\"token punctuation\">}</span></span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token keyword\">const</span> <span class=\"token punctuation\">{</span> getItem <span class=\"token punctuation\">}</span> <span class=\"token operator\">=</span> <span class=\"token function\">useAsyncStorage</span><span class=\"token punctuation\">(</span><span class=\"token string\">'todo'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token keyword\">const</span> <span class=\"token punctuation\">[</span>items<span class=\"token punctuation\">,</span> setItems<span class=\"token punctuation\">]</span> <span class=\"token operator\">=</span> <span class=\"token function\">useState</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token keyword\">const</span> <span class=\"token punctuation\">[</span>loading<span class=\"token punctuation\">,</span> setLoading<span class=\"token punctuation\">]</span> <span class=\"token operator\">=</span> <span class=\"token function\">useState</span><span class=\"token punctuation\">(</span><span class=\"token boolean\">true</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n  <span class=\"token keyword\">function</span> <span class=\"token function\">getTodoList</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token function\">getItem</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span>\n      <span class=\"token punctuation\">.</span><span class=\"token function\">then</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">todoJSON</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\n        <span class=\"token keyword\">const</span> todo <span class=\"token operator\">=</span> todoJSON <span class=\"token operator\">?</span> <span class=\"token constant\">JSON</span><span class=\"token punctuation\">.</span><span class=\"token function\">parse</span><span class=\"token punctuation\">(</span>todoJSON<span class=\"token punctuation\">)</span> <span class=\"token operator\">:</span> <span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">;</span>\n        <span class=\"token function\">setItems</span><span class=\"token punctuation\">(</span>todo<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n        <span class=\"token function\">setLoading</span><span class=\"token punctuation\">(</span><span class=\"token boolean\">false</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n      <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span>\n      <span class=\"token punctuation\">.</span><span class=\"token function\">catch</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">err</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\n        console<span class=\"token punctuation\">.</span><span class=\"token function\">error</span><span class=\"token punctuation\">(</span>err<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n        Toast<span class=\"token punctuation\">.</span><span class=\"token function\">show</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\n          <span class=\"token literal-property property\">type</span><span class=\"token operator\">:</span> <span class=\"token string\">'error'</span><span class=\"token punctuation\">,</span>\n          <span class=\"token literal-property property\">text1</span><span class=\"token operator\">:</span> <span class=\"token string\">'An error occurred'</span><span class=\"token punctuation\">,</span>\n          <span class=\"token literal-property property\">position</span><span class=\"token operator\">:</span> <span class=\"token string\">'top'</span>\n        <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n      <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token punctuation\">}</span>\n\n  <span class=\"token keyword\">function</span> <span class=\"token function\">renderCard</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\"><span class=\"token punctuation\">{</span>item<span class=\"token punctuation\">}</span></span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token keyword\">return</span> <span class=\"token punctuation\">(</span>\n      <span class=\"token operator\">&#x3C;</span>Card<span class=\"token operator\">></span>\n        <span class=\"token operator\">&#x3C;</span>Card<span class=\"token punctuation\">.</span>Title style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>styles<span class=\"token punctuation\">.</span>cardTitle<span class=\"token punctuation\">}</span><span class=\"token operator\">></span><span class=\"token punctuation\">{</span>item<span class=\"token punctuation\">.</span>title<span class=\"token punctuation\">}</span><span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Card<span class=\"token punctuation\">.</span>Title<span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>Card<span class=\"token operator\">></span>\n    <span class=\"token punctuation\">)</span>\n  <span class=\"token punctuation\">}</span>\n  \n  <span class=\"token function\">useEffect</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\n    <span class=\"token keyword\">const</span> unsubscribe <span class=\"token operator\">=</span> navigation<span class=\"token punctuation\">.</span><span class=\"token function\">addListener</span><span class=\"token punctuation\">(</span><span class=\"token string\">'focus'</span><span class=\"token punctuation\">,</span> getTodoList<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n    <span class=\"token keyword\">return</span> unsubscribe<span class=\"token punctuation\">;</span>\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">)</span>\n\n  <span class=\"token keyword\">return</span> <span class=\"token punctuation\">(</span>\n    <span class=\"token operator\">&#x3C;</span>View<span class=\"token operator\">></span>\n      <span class=\"token operator\">&#x3C;</span>FlatList refreshing<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>loading<span class=\"token punctuation\">}</span> onRefresh<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>getTodoList<span class=\"token punctuation\">}</span> style<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>styles<span class=\"token punctuation\">.</span>list<span class=\"token punctuation\">}</span> data<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>items<span class=\"token punctuation\">}</span> \n        renderItem<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span>renderCard<span class=\"token punctuation\">}</span> keyExtractor<span class=\"token operator\">=</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">item</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> item<span class=\"token punctuation\">.</span>id<span class=\"token punctuation\">}</span> <span class=\"token operator\">/</span><span class=\"token operator\">></span>\n    <span class=\"token operator\">&#x3C;</span><span class=\"token operator\">/</span>View<span class=\"token operator\">></span>\n  <span class=\"token punctuation\">)</span>\n<span class=\"token punctuation\">}</span>\n\n<span class=\"token keyword\">const</span> styles <span class=\"token operator\">=</span> StyleSheet<span class=\"token punctuation\">.</span><span class=\"token function\">create</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\n  <span class=\"token literal-property property\">list</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token literal-property property\">width</span><span class=\"token operator\">:</span> <span class=\"token string\">'100%'</span>\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n  <span class=\"token literal-property property\">cardTitle</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token literal-property property\">textAlign</span><span class=\"token operator\">:</span> <span class=\"token string\">'left'</span>\n  <span class=\"token punctuation\">}</span>\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span></code></pre></div><p>Here's a breakdown of what this code is doing. First, we're using <code class=\"language-text\">useAsyncStorage</code> hook just like we did before to get a getter function for <code class=\"language-text\">todo</code>. We're also creating state variables <code class=\"language-text\">items</code> and <code class=\"language-text\">loading</code>. <code class=\"language-text\">items</code> will be used to store the items after fetching them from the storage. <code class=\"language-text\">loading</code> will be used to indicate that we're currently retrieving the items from the storage.</p><p>Then, we create the function <code class=\"language-text\">getTodoList</code>. This function should be executed every time the screen is opened. In this function, we're just using the getter function <code class=\"language-text\">getItem</code> like we did before and once we retrieve the todo list items from the storage, we're setting the state <code class=\"language-text\">items</code> and <code class=\"language-text\">loading</code>.</p><p>After that, we create the function <code class=\"language-text\">renderCard</code>. This function will be used to render each item in the FlatList. We'll be using the <a href=\"https://reactnativeelements.com/docs/card\">Card</a> component from React Native Element to display them.</p><p>Next is the important part. In <code class=\"language-text\">useEffect</code>, we are adding an event listener to the <code class=\"language-text\">focus</code> event for the <code class=\"language-text\">navigator</code> object that the screens inside the navigation stack receive as a prop. The focus event is triggered every time the screen comes into focus. So, this listener for the focus event will run when the app launch and the Home screen is shown, and when we go back from the <code class=\"language-text\">NewScreen</code> to the Home screen.</p><p>Finally, we're displaying the <code class=\"language-text\">FlatList</code> component. It receives the <code class=\"language-text\">refreshing</code> prop which indicates whether the list is currently refreshing. We're passing it the <code class=\"language-text\">loading</code> state. We're also passing it an event handler for the refresh event in the prop <code class=\"language-text\">onRefresh</code>. This event is triggered whenever the user refreshes the list by pulling it down.</p><p>The <code class=\"language-text\">data</code> prop indicates the data that we're displaying in the list and should be an array. The <code class=\"language-text\">renderItem</code> prop receives a function to render each item, and that function will be passed an object which includes the <code class=\"language-text\">item</code> property, indicating the current item to be rendered in the list. </p><p>The <code class=\"language-text\">keyExtractor</code> prop indicates how to assign the <code class=\"language-text\">key</code> prop for each item in the list. In React and React Native, when rendering an array of items you should pass a key <code class=\"language-text\">prop</code> to each item. We're setting the key for each item its id.</p><p>In the end, we're defining the stylesheet to style all elements.</p><p> If you open the app now, you'll see that on the Home Screen a list of items will appear which are items that you add in the <code class=\"language-text\">NewScreen</code>. Try going to the <code class=\"language-text\">NewScreen</code> again and adding more items. You'll see them added to the list.</p><figure class=\"kg-card kg-image-card\"><img src=\"https://backend.shahednasser.com/content/images/2021/09/IMG_7843.PNG\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"1242\" height=\"2208\" srcset=\"https://backend.shahednasser.com/content/images/size/w600/2021/09/IMG_7843.PNG 600w, https://backend.shahednasser.com/content/images/size/w1000/2021/09/IMG_7843.PNG 1000w, https://backend.shahednasser.com/content/images/2021/09/IMG_7843.PNG 1242w\" sizes=\"(min-width: 720px) 720px\"></figure><h2 id=\"publish-the-app\">Publish the App</h2><p>The last step that comes when creating an app is to publish it. React Native's documentation has a guide on how to publish your app on <a href=\"https://reactnative.dev/docs/signed-apk-android\">Google Play Store</a> and <a href=\"https://reactnative.dev/docs/publishing-to-app-store\">Apple App Store</a>.</p><p>If, however, you want to publish the app but you don't have a developer account for either Google or Apple, you can publish the <a href=\"https://docs.expo.dev/workflow/publishing/\">app on Expo</a>, but that would require anyone to install Expo to be able to try or use your app.</p><h2 id=\"conclusion\">Conclusion</h2><p>You just created your first app! You were able to create an app with navigation, forms, storage, lists, and more!</p><p>If you want to keep practicing, try adding a delete or edit functionality. Make sure to check more of React Native's <a href=\"https://reactnative.dev\">documentation</a> as well as React Navigation's documentation on <a href=\"https://reactnavigation.org/docs/params\">how to pass parameters</a> as well.</p>","htmlAst":{"type":"root","children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"https://reactnative.dev"},"children":[{"type":"text","value":"React Native"}]},{"type":"text","value":" is one of the most popular frameworks that allow you to create cross-platform apps using JavaScript. Using React Native, you'll be able to write one code for the web, iOS, and Android."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In this tutorial, you'll learn the basics of creating a React Native app with "},{"type":"element","tagName":"a","properties":{"href":"https://expo.dev"},"children":[{"type":"text","value":"Expo"}]},{"type":"text","value":". We'll create a to-do list app where we'll learn about implementing navigation in a React Native app and storing data in our app."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can find the code for this tutorial in "},{"type":"element","tagName":"a","properties":{"href":"https://github.com/shahednasser/react-native-tutorial"},"children":[{"type":"text","value":"this GitHub Repository"}]},{"type":"text","value":". You can also "},{"type":"element","tagName":"a","properties":{"href":"https://expo.dev/@shahednasser/todolist"},"children":[{"type":"text","value":"install the app"}]},{"type":"text","value":" using Expo Go. There is more info on how to install Expo Go below."}]},{"type":"element","tagName":"h2","properties":{"id":"prerequisites"},"children":[{"type":"text","value":"Prerequisites"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Before you start going through the tutorial, you'll need to install "},{"type":"element","tagName":"a","properties":{"href":"https://nodejs.org/en/"},"children":[{"type":"text","value":"Node.js"}]},{"type":"text","value":" which will install NPM with it."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You also need to install Expo. Expo provides a set of tools to make your mobile development with React Native easier. "}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To install Expo run:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" -g expo-cli"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Finally, you'll need to install "},{"type":"element","tagName":"a","properties":{"href":"https://expo.dev/client"},"children":[{"type":"text","value":"Expo Go"}]},{"type":"text","value":" on your phone. It's available for both "},{"type":"element","tagName":"a","properties":{"href":"https://play.google.com/store/apps/details?id=host.exp.exponent&hl=en&gl=US"},"children":[{"type":"text","value":"Android"}]},{"type":"text","value":" and "},{"type":"element","tagName":"a","properties":{"href":"https://apps.apple.com/us/app/expo-go/id982107779"},"children":[{"type":"text","value":"iOS"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"By installing Expo Go on your phone, you'll be able to test your app directly on your phone as you make changes. "}]},{"type":"element","tagName":"h2","properties":{"id":"setup-project"},"children":[{"type":"text","value":"Setup Project"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To create a new React Native project, run the following command in your terminal:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"expo init todolist"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You'll be asked to choose the kind of project you want to create, choose "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"blank"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"After you choose "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"blank"}]},{"type":"text","value":", the project will be set up and the minimal dependencies required to create an app with React Native will be installed."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"After the setup is done, change to the directory of the project:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","builtin","class-name"]},"children":[{"type":"text","value":"cd"}]},{"type":"text","value":" todolist"}]}]}]},{"type":"element","tagName":"h2","properties":{"id":"project-structure"},"children":[{"type":"text","value":"Project Structure"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's take a quick look at the project's structure before we start coding."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2021/09/Screen-Shot-2021-09-25-at-9.56.47-PM.png","className":["kg-image"],"alt":"","loading":"lazy","width":548,"height":578},"children":[]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We have the usual "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"package.json"}]},{"type":"text","value":" files that you find in every NPM project."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"There's "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"app.json"}]},{"type":"text","value":". This includes a set of configurations for our app. If you open it, you'll find key-value pairs related to the app name, version, icon, splash screen, and more."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"App.js"}]},{"type":"text","value":" is the entry point of our app. It's where we will start writing our app's code."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"assets"}]},{"type":"text","value":" directory includes images like the app icon, splash screen, and more."}]},{"type":"element","tagName":"h3","properties":{"id":"understand-first-components-in-react-native"},"children":[{"type":"text","value":"Understand First Components in React Native"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If you open "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"App.js"}]},{"type":"text","value":", you'll find content similar to this:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" StatusBar "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'expo-status-bar'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" React "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" StyleSheet"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" Text"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" View "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"export"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"default"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"App"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"View style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"styles"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"container"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Text"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"Open up App"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"js to start working on your app"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"!"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Text"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"StatusBar style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"auto\""}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"View"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" styles "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" StyleSheet"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"create"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"container"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"flex"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"1"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"backgroundColor"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'#fff'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"alignItems"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'center'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"justifyContent"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'center'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This is our first component! As you can see, components like "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"View"}]},{"type":"text","value":", "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Text"}]},{"type":"text","value":" and others imported from "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"react-native"}]},{"type":"text","value":" are being used."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You should know that in React Native when displaying the text you need to do it inside a "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Text"}]},{"type":"text","value":" component. "}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"React Native provides a set of components that will be later transformed into native components in iOS or Android."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We also create stylesheets to add styling to our components using "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"StyleSheet.create"}]},{"type":"text","value":", where "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"StyleSheet"}]},{"type":"text","value":" is imported from "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"react-native"}]},{"type":"text","value":" as well."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"create"}]},{"type":"text","value":" method takes an object of properties, which act like class names in CSS, and their values are objects of CSS-like properties and their values. Styling your components in React Native is almost identical to styling using CSS, with a few changes in some behaviors of some CSS properties."}]},{"type":"element","tagName":"h2","properties":{"id":"screens-and-navigation"},"children":[{"type":"text","value":"Screens and Navigation"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Now, we'll start adding screens to our app. To add different screens and manage navigation between them, we'll use "},{"type":"element","tagName":"a","properties":{"href":"https://reactnavigation.org/"},"children":[{"type":"text","value":"React Navigation"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"For an elaborate tutorial on Navigation, check out my tutorial "},{"type":"element","tagName":"a","properties":{"href":"https://blog.shahednasser.com/react-native-navigation-tutorial/"},"children":[{"type":"text","value":"React Native Navigation Tutorial"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"h3","properties":{"id":"home-screen"},"children":[{"type":"text","value":"Home Screen"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Create the directories "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"src/screens"}]},{"type":"text","value":". The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"screens"}]},{"type":"text","value":" directory will hold all the screens we will create later on."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Then, create "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"HomeScreen.js"}]},{"type":"text","value":" inside "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"screens"}]},{"type":"text","value":". This will be the first screen that the user will see when they open the app."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Add the following content inside "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"HomeScreen.js"}]},{"type":"text","value":":"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" React "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" Text"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" View "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"export"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"default"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"HomeScreen"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"View"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Text"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"Welcome Home"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"!"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Text"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"View"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The home screen, at the moment, will just display the text \"Welcome Home!\"."}]},{"type":"element","tagName":"h3","properties":{"id":"install-react-navigation"},"children":[{"type":"text","value":"Install React Navigation"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Next, we'll see how to use multiple screens with React Navigation."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"React Navigation allows us to move between screens backward and forwards, add buttons to the header, and more."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To install React Navigation, run the following commands:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" @react-navigation/native\nexpo "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" react-native-screens react-native-safe-area-context\n"},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" @react-navigation/native-stack"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Once these commands are done executing, we'll have all the dependencies required to use React Navigation."}]},{"type":"element","tagName":"h3","properties":{"id":"how-react-navigation-works"},"children":[{"type":"text","value":"How React Navigation Works"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To put things simply, React Navigation manages screens, navigation between them, and history as a Stack. "}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"There's a default, initial screen that shows when the app is launched. Then, when you want to open a new screen, you can push it at the top of the stack or replace the current item in the stack."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Then, when you want to go backward, you pop the current item at the top of the stack and show the one below it, which was the previous screen, until you reach the home, initial screen."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":" If it sounds confusing at the moment, keep going through in the tutorial and you'll start understanding things more."}]},{"type":"element","tagName":"h3","properties":{"id":"create-the-navigation-stack"},"children":[{"type":"text","value":"Create the Navigation Stack"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Change the content of "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"App.js"}]},{"type":"text","value":" to the following:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native-gesture-handler'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" React "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" createStackNavigator "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'@react-navigation/stack'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" NavigationContainer "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'@react-navigation/native'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" HomeScreen "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'./src/screens/HomeScreen'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" Stack "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"createStackNavigator"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"export"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"default"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"App"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"NavigationContainer"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Stack"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Navigator initialRouteName"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Home\""}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Stack"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Screen name"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Home\""}]},{"type":"text","value":" component"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"HomeScreen"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Stack"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Navigator"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"NavigationContainer"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's go over things bit by bit."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We first need to import "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"react-native-gesture-handler"}]},{"type":"text","value":" at the top of the app. This allows navigating using gestures. The higher in the app it's placed the better."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Next, we're importing "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"createStackNavigator"}]},{"type":"text","value":". This function returns a Stack object, which contains two components "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Screen"}]},{"type":"text","value":" and "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Navigator"}]},{"type":"text","value":". "}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Screen"}]},{"type":"text","value":" is used to display screen components that we create, define their options, and more. If you look at the example above, we provide a "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"name"}]},{"type":"text","value":" and "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"component"}]},{"type":"text","value":" props for a screen:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Stack"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Screen name"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Home\""}]},{"type":"text","value":" component"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"HomeScreen"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"name"}]},{"type":"text","value":" prop can be used to navigate to that screen at any given point later. The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"component"}]},{"type":"text","value":" prop will be used to define the screen component to render when the screen is navigated to."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Navigator"}]},{"type":"text","value":" should contain "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Screen"}]},{"type":"text","value":" components as children as it manages the routing between them. "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Navigator"}]},{"type":"text","value":" also receives the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"initialRouteName"}]},{"type":"text","value":" prop which determines the screen that should open when the app first launches."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Finally, we use "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NavigationContainer"}]},{"type":"text","value":" to wrap the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Navigator"}]},{"type":"text","value":" components, as it manages the navigation tree and state."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"So, in "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"App.js"}]},{"type":"text","value":", which will contain the navigation routes for the screens in the app as we go forward, we should render the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NavigationContainer"}]},{"type":"text","value":" and inside it "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Stack.Navigator"}]},{"type":"text","value":" which contains one or more "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Stack.Screen"}]},{"type":"text","value":" components:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"NavigationContainer"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Stack"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Navigator initialRouteName"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Home\""}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Stack"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Screen name"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Home\""}]},{"type":"text","value":" component"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"HomeScreen"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Stack"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Navigator"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"NavigationContainer"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]}]}]}]},{"type":"element","tagName":"h2","properties":{"id":"run-the-app"},"children":[{"type":"text","value":"Run the App"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's run the app now. To do that, open the terminal and run the following:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" start"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This will start Expo. As mentioned earlier, with Expo you will be able to run the app on your phone, so make sure you've installed Expo Go as detailed in the Prerequisites section."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"A web page will open that looks something like this:"}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2021/09/Screen-Shot-2021-09-26-at-3.16.27-PM.png","className":["kg-image"],"alt":"","loading":"lazy","width":2000,"height":1172,"srcSet":["https://backend.shahednasser.com/content/images/size/w600/2021/09/Screen-Shot-2021-09-26-at-3.16.27-PM.png 600w","https://backend.shahednasser.com/content/images/size/w1000/2021/09/Screen-Shot-2021-09-26-at-3.16.27-PM.png 1000w","https://backend.shahednasser.com/content/images/size/w1600/2021/09/Screen-Shot-2021-09-26-at-3.16.27-PM.png 1600w","https://backend.shahednasser.com/content/images/size/w2400/2021/09/Screen-Shot-2021-09-26-at-3.16.27-PM.png 2400w"],"sizes":"(min-width: 720px) 720px"},"children":[]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"There are multiple ways to run the app after this on your device. You can scan the QR code with your phone to open it in Expo Go. Alternatively, you can use one of the actions on the sidebar of the web page above like send link with email and so on."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Once you choose the best way to open the app on your phone and it opens, you should see the following screen:"}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2021/09/IMG_7813.PNG","className":["kg-image"],"alt":"","loading":"lazy","width":1242,"height":2208,"srcSet":["https://backend.shahednasser.com/content/images/size/w600/2021/09/IMG_7813.PNG 600w","https://backend.shahednasser.com/content/images/size/w1000/2021/09/IMG_7813.PNG 1000w","https://backend.shahednasser.com/content/images/2021/09/IMG_7813.PNG 1242w"],"sizes":"(min-width: 720px) 720px"},"children":[]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We've run our first app! We'll start customizing the styles of the header next and add more screens to create a Todo List app."}]},{"type":"element","tagName":"h2","properties":{"id":"style-the-header"},"children":[{"type":"text","value":"Style the Header"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"With React Navigation, there are 2 ways to style the header of a screen."}]},{"type":"element","tagName":"h3","properties":{"id":"style-screen-headers-individually"},"children":[{"type":"text","value":"Style Screen Headers Individually"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The first way is to style it for each screen. This can be done by passing the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"options"}]},{"type":"text","value":" prop to a "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Screen"}]},{"type":"text","value":" component like this:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Stack"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Screen \n    name"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Home\""}]},{"type":"text","value":" \n    component"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"HomeScreen"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" \n    options"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n\t\t"},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"headerStyle"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n\t\t\t"},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"backgroundColor"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'#228CDB'"}]},{"type":"text","value":"\n\t\t"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"headerTintColor"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'#fff'"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" \n"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"options"}]},{"type":"text","value":" prop is an object of options for the screen. To style the header, we can use the following three properties:"}]},{"type":"element","tagName":"ol","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"headerStyle"}]},{"type":"text","value":": accepts an object of styles to apply to the header. To set the background color of the header, we pass it the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"backgroundColor"}]},{"type":"text","value":" prop with the value of the background color of the header."}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"headerTintColor"}]},{"type":"text","value":": the color of the text or buttons that are in the header."}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"headerTitleStyle"}]},{"type":"text","value":": accepts an object of font-related styles to make changes to the title in the header. For example, we can change the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"fontFamily"}]},{"type":"text","value":" or "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"fontWeight"}]},{"type":"text","value":"."}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Using this prop, we'll be able to style the header of a screen."}]},{"type":"element","tagName":"h3","properties":{"id":"style-all-screen-headers"},"children":[{"type":"text","value":"Style All Screen Headers"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In general cases, styling each screen separately is tedious and leads to repeated code. Usually, you'd apply the same header style to all screens in the app."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In this case, we can use the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"screenOptions"}]},{"type":"text","value":" prop on the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Navigator"}]},{"type":"text","value":" component. This prop accepts the same header options as the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"options"}]},{"type":"text","value":" prop in the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Screen"}]},{"type":"text","value":" component and applies the styling to all screens."}]},{"type":"element","tagName":"h3","properties":{"id":"apply-header-styles-in-our-app"},"children":[{"type":"text","value":"Apply Header Styles in Our App"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In our app, we'll apply the same header style to all the screens in the app. So, we'll use the second way to style a header."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In App.js, replace this line:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Stack"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Navigator initialRouteName"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Home\""}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"With the following:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Stack"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Navigator\n    screenOptions"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n\t\t\t"},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"headerStyle"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n\t\t\t\t"},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"backgroundColor"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'#228CDB'"}]},{"type":"text","value":"\n\t\t\t"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n        \t"},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"headerTintColor"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'#fff'"}]},{"type":"text","value":"\n    \t"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" \n    initialRouteName"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Home\""}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This will change the background color of the header to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"#228CDB"}]},{"type":"text","value":" and the color of the text and buttons in the header to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"#fff"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If you save the changes and open the app again, you'll see that the header color changed."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2021/09/IMG_7814.PNG","className":["kg-image"],"alt":"","loading":"lazy","width":1242,"height":2208,"srcSet":["https://backend.shahednasser.com/content/images/size/w600/2021/09/IMG_7814.PNG 600w","https://backend.shahednasser.com/content/images/size/w1000/2021/09/IMG_7814.PNG 1000w","https://backend.shahednasser.com/content/images/2021/09/IMG_7814.PNG 1242w"],"sizes":"(min-width: 720px) 720px"},"children":[]}]},{"type":"element","tagName":"h2","properties":{"id":"navigate-screens"},"children":[{"type":"text","value":"Navigate Screens"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Next, we'll see how to add another screen and navigate to it. We'll also see how to add a header button."}]},{"type":"element","tagName":"h3","properties":{"id":"add-new-screen"},"children":[{"type":"text","value":"Add New Screen"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We'll add a new screen, which we'll use later to add a new to-do list item. "}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Create "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"src/screens/NewScreen.js"}]},{"type":"text","value":" with the following content:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" React "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" Text"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" View "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"export"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"default"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"NewScreen"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"View"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Text"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"This is New Screen"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Text"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"View"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Similar to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"HomeScreen"}]},{"type":"text","value":", we're just showing the text \"This is New Screen\" for now."}]},{"type":"element","tagName":"h3","properties":{"id":"add-route-for-new-screen"},"children":[{"type":"text","value":"Add Route for New Screen"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Now, we need to add a new route in our navigation stack for the new route. In "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"App.js"}]},{"type":"text","value":" below the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Screen"}]},{"type":"text","value":" component for "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"HomeScreen"}]},{"type":"text","value":" add a new one for "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NewScreen"}]},{"type":"text","value":":"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Stack"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Screen name"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"New\""}]},{"type":"text","value":" component"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"NewScreen"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]}]}]}]},{"type":"element","tagName":"h3","properties":{"id":"add-header-button"},"children":[{"type":"text","value":"Add Header Button"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Next, we'll add a header button on the Home screen. It will be a plus button that should take us to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NewScreen"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To add a button to the header of a screen, we do it using the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"headerRight"}]},{"type":"text","value":" property of the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"options"}]},{"type":"text","value":" prop passed to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Screen"}]},{"type":"text","value":". The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"headerRight"}]},{"type":"text","value":" property accepts a function that should return a component to render."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Instead of using React Native's "},{"type":"element","tagName":"a","properties":{"href":"https://reactnative.dev/docs/button"},"children":[{"type":"text","value":"Button"}]},{"type":"text","value":" component, we'll use "},{"type":"element","tagName":"a","properties":{"href":"https://reactnativeelements.com"},"children":[{"type":"text","value":"React Native Elements"}]},{"type":"text","value":"' "},{"type":"element","tagName":"a","properties":{"href":"https://reactnativeelements.com/docs/icon"},"children":[{"type":"text","value":"Icon"}]},{"type":"text","value":" component. Adding a plus icon looks better than an actual button."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"So, let's first install React Native Elements in our project:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" i react-native-elements"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Then, change the following line in "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"App.js"}]},{"type":"text","value":":"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Stack"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Screen name"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Home\""}]},{"type":"text","value":" component"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"HomeScreen"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"to this:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Stack"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Screen \n    name"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Home\""}]},{"type":"text","value":" \n    component"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"HomeScreen"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" \n    options"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n         "},{"type":"element","tagName":"span","properties":{"className":["token","function-variable","function"]},"children":[{"type":"text","value":"headerRight"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n             "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Icon \n             name"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"plus\""}]},{"type":"text","value":" \n             type"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"feather\""}]},{"type":"text","value":" \n             color"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"#fff\""}]},{"type":"text","value":"\n             style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"style"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"headerIcon"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n         "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"As you can see, we are using the Icon component, passing it the prop "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"name"}]},{"type":"text","value":" which is the name of the icon to be used. "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"type"}]},{"type":"text","value":" as React Native Elements allow us to choose from multiple icon sets. We are using "},{"type":"element","tagName":"a","properties":{"href":"https://feathericons.com"},"children":[{"type":"text","value":"Feather"}]},{"type":"text","value":" icons. "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"color"}]},{"type":"text","value":" indicates the color of the icon. And finally, we're passing it "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"style"}]},{"type":"text","value":". Add the following to the end of "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"App.js"}]},{"type":"text","value":" to create a new stylesheet:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" style "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" StyleSheet"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"create"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"headerIcon"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"marginRight"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"10"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This will add a margin-right to the icon, as it won't have any by default."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If you run the app now, you'll see that a new + icon has been added to the header but it does nothing at the moment."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2021/09/IMG_7817.PNG","className":["kg-image"],"alt":"","loading":"lazy","width":1242,"height":2208,"srcSet":["https://backend.shahednasser.com/content/images/size/w600/2021/09/IMG_7817.PNG 600w","https://backend.shahednasser.com/content/images/size/w1000/2021/09/IMG_7817.PNG 1000w","https://backend.shahednasser.com/content/images/2021/09/IMG_7817.PNG 1242w"],"sizes":"(min-width: 720px) 720px"},"children":[]}]},{"type":"element","tagName":"h3","properties":{"id":"navigating-to-another-screen"},"children":[{"type":"text","value":"Navigating to Another Screen"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We need to navigate to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NewScreen"}]},{"type":"text","value":" when the plus icon is pressed."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In React Native, button's press events are handled by passing a listener in the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"onPress"}]},{"type":"text","value":" prop of the button. So, we'll need to pass a handler for "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"onPress"}]},{"type":"text","value":" to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Icon"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To navigate to another screen, we can use the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"navigation"}]},{"type":"text","value":" prop. The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"navigation"}]},{"type":"text","value":" prop is passed to every screen in the stack navigation. "}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Another way we can use the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"navigation"}]},{"type":"text","value":" prop is by changing the value that the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"options"}]},{"type":"text","value":" prop accepts of a "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Screen"}]},{"type":"text","value":" to a function. The function accepts as a parameter an object which contains "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"navigation"}]},{"type":"text","value":", and the function should return an object of options."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Then, using the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"navigation"}]},{"type":"text","value":" prop we can navigate to another screen with the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"navigate"}]},{"type":"text","value":" method:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"text","value":"navigation"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"navigate"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'New'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Where "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"navigate"}]},{"type":"text","value":" accepts the name of the screen we're navigating to."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"So, change the line for "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"HomeScreen"}]},{"type":"text","value":" in "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"App.js"}]},{"type":"text","value":" to the following:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Stack"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Screen \n    name"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Home\""}]},{"type":"text","value":" \n    component"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"HomeScreen"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" \n    options"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"navigation"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","function-variable","function"]},"children":[{"type":"text","value":"headerRight"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n            "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Icon \n            name"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"plus\""}]},{"type":"text","value":" \n            type"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"feather\""}]},{"type":"text","value":" \n            color"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"#fff\""}]},{"type":"text","value":"\n            style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"style"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"headerIcon"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n                                onPress"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" navigation"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"navigate"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'New'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n    \t\t"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n    \t"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If you open the app now and click on the plus icon, you'll be taken to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NewScreen"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2021/09/IMG_7818.PNG","className":["kg-image"],"alt":"","loading":"lazy","width":1242,"height":2208,"srcSet":["https://backend.shahednasser.com/content/images/size/w600/2021/09/IMG_7818.PNG 600w","https://backend.shahednasser.com/content/images/size/w1000/2021/09/IMG_7818.PNG 1000w","https://backend.shahednasser.com/content/images/2021/09/IMG_7818.PNG 1242w"],"sizes":"(min-width: 720px) 720px"},"children":[]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can also see that, by default, a back button is added to the header and you can use it to go backward in the navigation stack. If you click on it, you'll go back to the Home screen."}]},{"type":"element","tagName":"h2","properties":{"id":"new-todo-item-form"},"children":[{"type":"text","value":"New Todo Item Form"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Next, we'll add a form to add a new todo item in "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NewScreen"}]},{"type":"text","value":". To simplify creating a form, we'll use "},{"type":"element","tagName":"a","properties":{"href":"https://formik.org"},"children":[{"type":"text","value":"Formik"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If you're not familiar with Formik, it's a React and React Native library that aims to simplify the process of creating a form."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To install Formik, run the following command:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" formik --save"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Then, change the content of "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"src/screens/NewScreen.js"}]},{"type":"text","value":" to the following:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" Formik "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'formik'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" React "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" StyleSheet"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" View "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" Text "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native-elements'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" Button "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native-elements/dist/buttons/Button'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" Input "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native-elements/dist/input/Input'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"export"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"default"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"NewScreen"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"newTask"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"values"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n\t"},{"type":"element","tagName":"span","properties":{"className":["token","comment"]},"children":[{"type":"text","value":"//TODO save new task"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Formik\n      initialValues"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"title"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"''"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n      onSubmit"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"newTask"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"handleChange"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" handleBlur"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" handleSubmit"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" values"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"View style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"style"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"container"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Text h4"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"New Todo Item"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Text"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Input \n            placeholder"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Example: Cook, Clean, etc...\""}]},{"type":"text","value":" \n            onChangeText"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"handleChange"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'title'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n            onBlur"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"handleBlur"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'title'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n            style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"style"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"input"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Button title"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"\"Add\""}]},{"type":"text","value":" onPress"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"handleSubmit"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"style"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"button"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"View"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Formik"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" style "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" StyleSheet"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"create"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"container"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"marginTop"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"10"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"padding"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"10"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"input"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"marginTop"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","number"]},"children":[{"type":"text","value":"10"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"button"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"backgroundColor"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'#228CDB'"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's go over everything we just added. We first define a new function "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"newTask"}]},{"type":"text","value":" inside the component, which we'll use later to handle saving a new task."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Then, we're creating a form with Formik. In Formik, you can use the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Formik"}]},{"type":"text","value":" component and pass it "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"initialValues"}]},{"type":"text","value":" to define the fields and their initial values. We just have one field "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"title"}]},{"type":"text","value":" and its initial value is just an empty string."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We also pass the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Formik"}]},{"type":"text","value":" component an "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"onSubmit"}]},{"type":"text","value":" prop which is the function that should be executed when the form is submitted. We're passing it "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"newTask"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Inside the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Formik"}]},{"type":"text","value":" component, you use a function that has a set of parameters but most importantly are "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"handleChange"}]},{"type":"text","value":", "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"handleBlur"}]},{"type":"text","value":", "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"handleSubmit"}]},{"type":"text","value":", and "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"values"}]},{"type":"text","value":". The function should return a component to render."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If you're familiar with Formik when using it with React, you'll notice that this is slightly different than how you'd use it with React. As inputs in React Native are not similar to inputs on the web since they don't have names, you need to clearly specify for each input the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"onChange"}]},{"type":"text","value":" and "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"onBlur"}]},{"type":"text","value":" listeners passing them the name of the input."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"So, for the title "},{"type":"element","tagName":"a","properties":{"href":"https://reactnativeelements.com/docs/input"},"children":[{"type":"text","value":"Input"}]},{"type":"text","value":", which is a component we are using from React Native Elements, we pass for "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"onChange"}]},{"type":"text","value":" the listener "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"handleChange('title')"}]},{"type":"text","value":" and for "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"onBlur"}]},{"type":"text","value":" the listener "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"handleBlur('title')"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Then, we add a "},{"type":"element","tagName":"a","properties":{"href":"https://reactnativeelements.com/docs/button"},"children":[{"type":"text","value":"Button"}]},{"type":"text","value":" component, which is another component we are using from React Native Elements. We assign the listener for "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"onPress"}]},{"type":"text","value":" on the button to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"handleSubmit"}]},{"type":"text","value":". This means that when the button is pressed, the submit event will be triggered in the form, which will trigger "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"newTask"}]},{"type":"text","value":" since we assigned it as the listener to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"onSubmit"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Notice that we are adding some styling to the screen and components in it. We use the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"styles"}]},{"type":"text","value":" variable which is created with "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"StyleSheet.create"}]},{"type":"text","value":", and we pass to each component a style prop with its value a property in the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"styles"}]},{"type":"text","value":" variable. For example in "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"View"}]},{"type":"text","value":":"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"View style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"style"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"container"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If you open the app now, click on the plus button in the Home Screen which will open "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NewScreen"}]},{"type":"text","value":". You should see the form we just created."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2021/09/IMG_7819.PNG","className":["kg-image"],"alt":"","loading":"lazy","width":1242,"height":2208,"srcSet":["https://backend.shahednasser.com/content/images/size/w600/2021/09/IMG_7819.PNG 600w","https://backend.shahednasser.com/content/images/size/w1000/2021/09/IMG_7819.PNG 1000w","https://backend.shahednasser.com/content/images/2021/09/IMG_7819.PNG 1242w"],"sizes":"(min-width: 720px) 720px"},"children":[]}]},{"type":"element","tagName":"h3","properties":{"id":"handle-submit"},"children":[{"type":"text","value":"Handle Submit"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We'll now handle the submission of the form in the function "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"newTask"}]},{"type":"text","value":". What we'll do is take the title and store it in the app."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"There are many ways you can manage storage in React Native. We'll use "},{"type":"element","tagName":"a","properties":{"href":"https://react-native-async-storage.github.io/async-storage/"},"children":[{"type":"text","value":"Async Storage"}]},{"type":"text","value":". It provides a simple API to store data in your app. For data that are not too complex, like settings related to the user or app, it's a great choice."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We'll use Async Storage to store the todo list items in our app. So, let's first install it:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"expo "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" @react-native-async-storage/async-storage"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"AsyncStorage has 2 functions in its API. getItem and setItem. using setItem, you set items serialized as strings. So, if you have an array or object you need to stringify them with "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"JSON.stringify"}]},{"type":"text","value":". Then, you can retrieve the item with "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"getItem"}]},{"type":"text","value":" and you'll have to parse the JSON if it's stringified with "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"JSON.parse"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Add the following import at the beginning of "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NewScreen.js"}]},{"type":"text","value":" along with the rest of the imports added before:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" useAsyncStorage "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'@react-native-async-storage/async-storage'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Then, inside the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NewScreen"}]},{"type":"text","value":" component, add the following line:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" getItem"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" setItem "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"useAsyncStorage"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'todo'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We are using the "},{"type":"element","tagName":"a","properties":{"href":"https://react-native-async-storage.github.io/async-storage/docs/api#useasyncstorage"},"children":[{"type":"text","value":"useAsyncStorage"}]},{"type":"text","value":" hook which allows us to pass the name of a key in the storage and retrieve a getter "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"getItem"}]},{"type":"text","value":" and a setter "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"setItem"}]},{"type":"text","value":" solely for that key in the storage."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Before we start implementing the functionality inside "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"newTask"}]},{"type":"text","value":", we need 2 other dependencies: "},{"type":"element","tagName":"a","properties":{"href":"https://www.npmjs.com/package/react-native-uuid"},"children":[{"type":"text","value":"react-native-uuid"}]},{"type":"text","value":" to generate random IDs for every task in storage, and "},{"type":"element","tagName":"a","properties":{"href":"https://www.npmjs.com/package/react-native-toast-message"},"children":[{"type":"text","value":"react-native-toast-message"}]},{"type":"text","value":" to show toast messages if an error occurs:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"bash"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"npm"}]},{"type":"text","value":" i react-native-uuid react-native-toast-message"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"For react-native-toast-message to work, we first need to add a "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Toast"}]},{"type":"text","value":" component in one of the higher components rendered in the App. So, add the following line in "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"App.js"}]},{"type":"text","value":" before the closing of "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NavigationContainer"}]},{"type":"text","value":":"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"text","value":"\t"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Toast ref"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"ref"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" Toast"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setRef"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"ref"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"NavigationContainer"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"And, of course, add the necessary import at the beginning of "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"App.js"}]},{"type":"text","value":":"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" Toast "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native-toast-message'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Back to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NewScreen.js"}]},{"type":"text","value":". We'll now implement "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"newTask"}]},{"type":"text","value":". We'll first validate that the user entered a value for "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"title"}]},{"type":"text","value":". Then, we'll get the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"todo"}]},{"type":"text","value":" items from the storage, which will be an array of objects where each object is a to-do item. Then, we'll push a new item into the array and set the item in storage again."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Change the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"newTask"}]},{"type":"text","value":" function to the following:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"newTask"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"values"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"if"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"!"}]},{"type":"text","value":"values"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"title"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n      Toast"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"show"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"type"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'error'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"text1"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'Title is required'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"position"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'top'"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","comment"]},"children":[{"type":"text","value":"//get todo array from storage"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"getItem"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"then"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"todoJSON"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"let"}]},{"type":"text","value":" todo "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" todoJSON "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"?"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","constant"]},"children":[{"type":"text","value":"JSON"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"parse"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"todoJSON"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","comment"]},"children":[{"type":"text","value":"//add a new item to the list"}]},{"type":"text","value":"\n        todo"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"push"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"id"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" uuid"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"v4"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"title"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" values"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"title\n        "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n        "},{"type":"element","tagName":"span","properties":{"className":["token","comment"]},"children":[{"type":"text","value":"//set item in storage again"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setItem"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","constant"]},"children":[{"type":"text","value":"JSON"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"stringify"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"todo"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"then"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n            "},{"type":"element","tagName":"span","properties":{"className":["token","comment"]},"children":[{"type":"text","value":"//navigate back to home screen"}]},{"type":"text","value":"\n            navigation"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"goBack"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"catch"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"err"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n            console"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"error"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"err"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n            Toast"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"show"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n              "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"type"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'error'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n              "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"text1"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'An error occurred and a new item could not be saved'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n              "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"position"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'top'"}]},{"type":"text","value":"\n            "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"catch"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"err"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n        console"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"error"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"err"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n        Toast"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"show"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"type"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'error'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"text1"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'An error occurred and a new item could not be saved'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"position"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'bottom'"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"As you can see, we're checking first if "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"values.title"}]},{"type":"text","value":" has been entered. If not, we show a toast message and return. To show a toast message using react-native-toast-message you need to pass it an object of options. There are a variety of options you can use, but the most important here are "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"type"}]},{"type":"text","value":" which can be "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"error"}]},{"type":"text","value":", "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"success"}]},{"type":"text","value":", or "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"info"}]},{"type":"text","value":", "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"position"}]},{"type":"text","value":" which can be "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"top"}]},{"type":"text","value":" or "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"bottom"}]},{"type":"text","value":", and "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"text1"}]},{"type":"text","value":" which will be the message to show in the toast."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"After validating "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"title"}]},{"type":"text","value":", we then use "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"getItem"}]},{"type":"text","value":" to retrieve "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"todo"}]},{"type":"text","value":" from the storage if it exists. "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"getItem"}]},{"type":"text","value":" returns a Promise as it is asynchronous, and the value of "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"todo"}]},{"type":"text","value":" is passed to "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"then"}]},{"type":"text","value":" function handler."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Inside "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"then"}]},{"type":"text","value":" we parse the JSON, then push a new to-do item. Each todo item will have an "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"id"}]},{"type":"text","value":" which is randomly generated, and a "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"title"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Finally, we set the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"todo"}]},{"type":"text","value":" array in the storage again as JSON. Once it is set successfully, we navigate back to the Home screen with "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"navigation.goBack"}]},{"type":"text","value":". As we mentioned earlier, all items in the navigation stack receive "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"navigation"}]},{"type":"text","value":" as a prop. So, make sure to add the prop for "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NewScreen"}]},{"type":"text","value":":"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"export"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"default"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"NewScreen"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" navigation "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can now try the form. Open the app and go to the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NewScreen"}]},{"type":"text","value":". Try first to submit the form without entering a title. You should see then a message telling you that the Title is required."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2021/09/IMG_7841.PNG","className":["kg-image"],"alt":"","loading":"lazy","width":1242,"height":2208,"srcSet":["https://backend.shahednasser.com/content/images/size/w600/2021/09/IMG_7841.PNG 600w","https://backend.shahednasser.com/content/images/size/w1000/2021/09/IMG_7841.PNG 1000w","https://backend.shahednasser.com/content/images/2021/09/IMG_7841.PNG 1242w"],"sizes":"(min-width: 720px) 720px"},"children":[]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Now try to enter a title and press \"Add\". You'll be navigated back to the Home Screen. That means that the item was added successfully!"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"What's left for us to do is display them on the Home Screen."}]},{"type":"element","tagName":"h3","properties":{"id":"display-tasks"},"children":[{"type":"text","value":"Display Tasks"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We'll now change the content of the Home Screen to display the todo list items we are adding in "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NewScreen"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To do so, we'll use the same function we used in "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NewScreen"}]},{"type":"text","value":" from Async Storage to get the items. To display the items, we'll use "},{"type":"element","tagName":"a","properties":{"href":"https://reactnative.dev/docs/flatlist"},"children":[{"type":"text","value":"FlatList"}]},{"type":"text","value":", a component that allows us to display a list of items easily."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Change the content of "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"HomeScreen"}]},{"type":"text","value":" to the following:"}]},{"type":"element","tagName":"div","properties":{"className":["kg-card","kg-code-card","gatsby-highlight"],"dataLanguage":"js"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-js"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" useAsyncStorage "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'@react-native-async-storage/async-storage'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" React"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" useEffect"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" useState "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" FlatList"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" StyleSheet"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" Text"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" View "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" Card "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native-elements'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" Toast "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'react-native-toast-message'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"export"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"default"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"HomeScreen"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" navigation "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":" getItem "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"useAsyncStorage"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'todo'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"text","value":"items"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" setItems"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"useState"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"text","value":"loading"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" setLoading"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"useState"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","boolean"]},"children":[{"type":"text","value":"true"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"getTodoList"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"getItem"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"then"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"todoJSON"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" todo "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" todoJSON "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"?"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","constant"]},"children":[{"type":"text","value":"JSON"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"parse"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"todoJSON"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setItems"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"todo"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"setLoading"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","boolean"]},"children":[{"type":"text","value":"false"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"catch"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"err"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n        console"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"error"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"err"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n        Toast"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"show"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"type"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'error'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"text1"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'An error occurred'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n          "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"position"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'top'"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"function"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"renderCard"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"item"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n        "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Title style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"styles"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"cardTitle"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"item"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"title"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"Title"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"Card"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n  \n  "},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"useEffect"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" unsubscribe "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" navigation"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"addListener"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'focus'"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" getTodoList"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n\n    "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"text","value":" unsubscribe"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":";"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"["}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"]"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n\n  "},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"return"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"View"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n      "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"text","value":"FlatList refreshing"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"loading"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" onRefresh"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"getTodoList"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" style"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"styles"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"list"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" data"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"items"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" \n        renderItem"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"renderCard"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" keyExtractor"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","parameter"]},"children":[{"type":"text","value":"item"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"=>"}]},{"type":"text","value":" item"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"text","value":"id"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"<"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"/"}]},{"type":"text","value":"View"},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":">"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n\n"},{"type":"element","tagName":"span","properties":{"className":["token","keyword"]},"children":[{"type":"text","value":"const"}]},{"type":"text","value":" styles "},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":"="}]},{"type":"text","value":" StyleSheet"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"."}]},{"type":"element","tagName":"span","properties":{"className":["token","function"]},"children":[{"type":"text","value":"create"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"("}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"list"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"width"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'100%'"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":","}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"cardTitle"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"{"}]},{"type":"text","value":"\n    "},{"type":"element","tagName":"span","properties":{"className":["token","literal-property","property"]},"children":[{"type":"text","value":"textAlign"}]},{"type":"element","tagName":"span","properties":{"className":["token","operator"]},"children":[{"type":"text","value":":"}]},{"type":"text","value":" "},{"type":"element","tagName":"span","properties":{"className":["token","string"]},"children":[{"type":"text","value":"'left'"}]},{"type":"text","value":"\n  "},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":"}"}]},{"type":"element","tagName":"span","properties":{"className":["token","punctuation"]},"children":[{"type":"text","value":")"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Here's a breakdown of what this code is doing. First, we're using "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"useAsyncStorage"}]},{"type":"text","value":" hook just like we did before to get a getter function for "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"todo"}]},{"type":"text","value":". We're also creating state variables "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"items"}]},{"type":"text","value":" and "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"loading"}]},{"type":"text","value":". "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"items"}]},{"type":"text","value":" will be used to store the items after fetching them from the storage. "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"loading"}]},{"type":"text","value":" will be used to indicate that we're currently retrieving the items from the storage."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Then, we create the function "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"getTodoList"}]},{"type":"text","value":". This function should be executed every time the screen is opened. In this function, we're just using the getter function "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"getItem"}]},{"type":"text","value":" like we did before and once we retrieve the todo list items from the storage, we're setting the state "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"items"}]},{"type":"text","value":" and "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"loading"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"After that, we create the function "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"renderCard"}]},{"type":"text","value":". This function will be used to render each item in the FlatList. We'll be using the "},{"type":"element","tagName":"a","properties":{"href":"https://reactnativeelements.com/docs/card"},"children":[{"type":"text","value":"Card"}]},{"type":"text","value":" component from React Native Element to display them."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Next is the important part. In "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"useEffect"}]},{"type":"text","value":", we are adding an event listener to the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"focus"}]},{"type":"text","value":" event for the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"navigator"}]},{"type":"text","value":" object that the screens inside the navigation stack receive as a prop. The focus event is triggered every time the screen comes into focus. So, this listener for the focus event will run when the app launch and the Home screen is shown, and when we go back from the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NewScreen"}]},{"type":"text","value":" to the Home screen."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Finally, we're displaying the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"FlatList"}]},{"type":"text","value":" component. It receives the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"refreshing"}]},{"type":"text","value":" prop which indicates whether the list is currently refreshing. We're passing it the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"loading"}]},{"type":"text","value":" state. We're also passing it an event handler for the refresh event in the prop "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"onRefresh"}]},{"type":"text","value":". This event is triggered whenever the user refreshes the list by pulling it down."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"data"}]},{"type":"text","value":" prop indicates the data that we're displaying in the list and should be an array. The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"renderItem"}]},{"type":"text","value":" prop receives a function to render each item, and that function will be passed an object which includes the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"item"}]},{"type":"text","value":" property, indicating the current item to be rendered in the list. "}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"keyExtractor"}]},{"type":"text","value":" prop indicates how to assign the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"key"}]},{"type":"text","value":" prop for each item in the list. In React and React Native, when rendering an array of items you should pass a key "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"prop"}]},{"type":"text","value":" to each item. We're setting the key for each item its id."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In the end, we're defining the stylesheet to style all elements."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":" If you open the app now, you'll see that on the Home Screen a list of items will appear which are items that you add in the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NewScreen"}]},{"type":"text","value":". Try going to the "},{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"NewScreen"}]},{"type":"text","value":" again and adding more items. You'll see them added to the list."}]},{"type":"element","tagName":"figure","properties":{"className":["kg-card","kg-image-card"]},"children":[{"type":"element","tagName":"img","properties":{"src":"https://backend.shahednasser.com/content/images/2021/09/IMG_7843.PNG","className":["kg-image"],"alt":"","loading":"lazy","width":1242,"height":2208,"srcSet":["https://backend.shahednasser.com/content/images/size/w600/2021/09/IMG_7843.PNG 600w","https://backend.shahednasser.com/content/images/size/w1000/2021/09/IMG_7843.PNG 1000w","https://backend.shahednasser.com/content/images/2021/09/IMG_7843.PNG 1242w"],"sizes":"(min-width: 720px) 720px"},"children":[]}]},{"type":"element","tagName":"h2","properties":{"id":"publish-the-app"},"children":[{"type":"text","value":"Publish the App"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The last step that comes when creating an app is to publish it. React Native's documentation has a guide on how to publish your app on "},{"type":"element","tagName":"a","properties":{"href":"https://reactnative.dev/docs/signed-apk-android"},"children":[{"type":"text","value":"Google Play Store"}]},{"type":"text","value":" and "},{"type":"element","tagName":"a","properties":{"href":"https://reactnative.dev/docs/publishing-to-app-store"},"children":[{"type":"text","value":"Apple App Store"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If, however, you want to publish the app but you don't have a developer account for either Google or Apple, you can publish the "},{"type":"element","tagName":"a","properties":{"href":"https://docs.expo.dev/workflow/publishing/"},"children":[{"type":"text","value":"app on Expo"}]},{"type":"text","value":", but that would require anyone to install Expo to be able to try or use your app."}]},{"type":"element","tagName":"h2","properties":{"id":"conclusion"},"children":[{"type":"text","value":"Conclusion"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You just created your first app! You were able to create an app with navigation, forms, storage, lists, and more!"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If you want to keep practicing, try adding a delete or edit functionality. Make sure to check more of React Native's "},{"type":"element","tagName":"a","properties":{"href":"https://reactnative.dev"},"children":[{"type":"text","value":"documentation"}]},{"type":"text","value":" as well as React Navigation's documentation on "},{"type":"element","tagName":"a","properties":{"href":"https://reactnavigation.org/docs/params"},"children":[{"type":"text","value":"how to pass parameters"}]},{"type":"text","value":" as well."}]}],"data":{"quirksMode":false}},"tableOfContents":[{"id":"prerequisites","heading":"Prerequisites"},{"id":"setup-project","heading":"Setup Project"},{"id":"project-structure","heading":"Project Structure","items":[{"id":"understand-first-components-in-react-native","heading":"Understand First Components in React Native"}]},{"id":"screens-and-navigation","heading":"Screens and Navigation","items":[{"id":"home-screen","heading":"Home Screen"},{"id":"install-react-navigation","heading":"Install React Navigation"},{"id":"how-react-navigation-works","heading":"How React Navigation Works"},{"id":"create-the-navigation-stack","heading":"Create the Navigation Stack"}]},{"id":"run-the-app","heading":"Run the App"},{"id":"style-the-header","heading":"Style the Header","items":[{"id":"style-screen-headers-individually","heading":"Style Screen Headers Individually"},{"id":"style-all-screen-headers","heading":"Style All Screen Headers"},{"id":"apply-header-styles-in-our-app","heading":"Apply Header Styles in Our App"}]},{"id":"navigate-screens","heading":"Navigate Screens","items":[{"id":"add-new-screen","heading":"Add New Screen"},{"id":"add-route-for-new-screen","heading":"Add Route for New Screen"},{"id":"add-header-button","heading":"Add Header Button"},{"id":"navigating-to-another-screen","heading":"Navigating to Another Screen"}]},{"id":"new-todo-item-form","heading":"New Todo Item Form","items":[{"id":"handle-submit","heading":"Handle Submit"},{"id":"display-tasks","heading":"Display Tasks"}]},{"id":"publish-the-app","heading":"Publish the App"},{"id":"conclusion","heading":"Conclusion"}]},"featureImageSharp":{"base":"jonathan-kemper-t6Wmvbw_MdI-unsplash-2-2.jpg","publicURL":"/static/9cf7bd6f419e5efbda67610c5d80d321/jonathan-kemper-t6Wmvbw_MdI-unsplash-2-2.jpg","imageMeta":{"width":1920,"height":1280},"childImageSharp":{"fluid":{"base64":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAANABQDASIAAhEBAxEB/8QAGAAAAwEBAAAAAAAAAAAAAAAAAAIFAwT/xAAVAQEBAAAAAAAAAAAAAAAAAAABAP/aAAwDAQACEAMQAAABi0eNgUwG/8QAGBAAAwEBAAAAAAAAAAAAAAAAAAECEQP/2gAIAQEAAQUCS0crmaIt7J//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAEDAQE/AT//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAECAQE/AT//xAAXEAADAQAAAAAAAAAAAAAAAAAAASBx/9oACAEBAAY/AhZP/8QAGhAAAwEAAwAAAAAAAAAAAAAAAAERQSFhkf/aAAgBAQABPyGwXVzaIejdDZPDw//aAAwDAQACAAMAAAAQKM//xAAWEQEBAQAAAAAAAAAAAAAAAAARARD/2gAIAQMBAT8QKsz/xAAXEQADAQAAAAAAAAAAAAAAAAAAARFB/9oACAECAQE/ELjIf//EABkQAQADAQEAAAAAAAAAAAAAAAEAETFRgf/aAAgBAQABPxBqcDWNSCeKp5Li03kGkAXDKONbl9F5P//Z","aspectRatio":1.4957264957264957,"src":"/static/9cf7bd6f419e5efbda67610c5d80d321/ea4ab/jonathan-kemper-t6Wmvbw_MdI-unsplash-2-2.jpg","srcSet":"/static/9cf7bd6f419e5efbda67610c5d80d321/477ba/jonathan-kemper-t6Wmvbw_MdI-unsplash-2-2.jpg 175w,\n/static/9cf7bd6f419e5efbda67610c5d80d321/06776/jonathan-kemper-t6Wmvbw_MdI-unsplash-2-2.jpg 350w,\n/static/9cf7bd6f419e5efbda67610c5d80d321/ea4ab/jonathan-kemper-t6Wmvbw_MdI-unsplash-2-2.jpg 700w,\n/static/9cf7bd6f419e5efbda67610c5d80d321/3055e/jonathan-kemper-t6Wmvbw_MdI-unsplash-2-2.jpg 1050w,\n/static/9cf7bd6f419e5efbda67610c5d80d321/eff08/jonathan-kemper-t6Wmvbw_MdI-unsplash-2-2.jpg 1400w,\n/static/9cf7bd6f419e5efbda67610c5d80d321/74fd5/jonathan-kemper-t6Wmvbw_MdI-unsplash-2-2.jpg 1920w","srcWebp":"/static/9cf7bd6f419e5efbda67610c5d80d321/89afa/jonathan-kemper-t6Wmvbw_MdI-unsplash-2-2.webp","srcSetWebp":"/static/9cf7bd6f419e5efbda67610c5d80d321/9fca7/jonathan-kemper-t6Wmvbw_MdI-unsplash-2-2.webp 175w,\n/static/9cf7bd6f419e5efbda67610c5d80d321/37a4e/jonathan-kemper-t6Wmvbw_MdI-unsplash-2-2.webp 350w,\n/static/9cf7bd6f419e5efbda67610c5d80d321/89afa/jonathan-kemper-t6Wmvbw_MdI-unsplash-2-2.webp 700w,\n/static/9cf7bd6f419e5efbda67610c5d80d321/78e7a/jonathan-kemper-t6Wmvbw_MdI-unsplash-2-2.webp 1050w,\n/static/9cf7bd6f419e5efbda67610c5d80d321/03d34/jonathan-kemper-t6Wmvbw_MdI-unsplash-2-2.webp 1400w,\n/static/9cf7bd6f419e5efbda67610c5d80d321/6833b/jonathan-kemper-t6Wmvbw_MdI-unsplash-2-2.webp 1920w","sizes":"(max-width: 700px) 100vw, 700px"}}}}}]}},"pageContext":{"slug":"5-tips-to-become-a-react-native-developer","prev":"medusa-create-fast-and-highly-customizable-ecommerce-store","next":"top-9-software-ideas-for-start-ups-for-the-year-2022","tag":"react-native","limit":3,"skip":0,"primaryTagCount":4,"collectionPaths":{}}},"staticQueryHashes":["1272700106","1676991999","2138873178","2546165603","2681841279","2938721187","293880488","3052966952","4156497161"]}