React Context for React Native - How to Access Data From Further Down the Component Tree

Published: 03 April 2022
on channel: MissCoding
466
17

Hi everyone!

Today, I will share with you how to use React’s Context within your React Native App! While this tutorial is for react native, the same will apply if you use Context in your React website. I will show you how to setup a provider with a default value and how to override that default value and then consume the data which is shared throughout your app. This can keep your code cleaner where you need to access data from multiple places. This is commonly used for providing a shared theme throughout the application. I have personally used it in a tab bar application to provide a shared state between all tabs.

You will find React’s documentation on Context here:
https://reactjs.org/docs/context.html

And you can find my usage of React Context in today’s tutorial here:
https://github.com/chelseafarley/Reac...

You can see my usage of the React Context in my xchangr app here:
Context: https://github.com/chelseafarley/xcha...
Provider: https://github.com/chelseafarley/xcha...
Consumers:
https://github.com/chelseafarley/xcha...
https://github.com/chelseafarley/xcha...

You’ve clearly come here to learn and a free audible trial allows you to increase your learning potential in situations where you may be hands free like at the gym or on your commute. It allows you to spend more time on theory when you aren’t able to watch a screen, so that you can maximise your screen time to pick up technical skills. Try it for free today:
https://amzn.to/3ECMsom

// ABOUT ME
My name is Chelsea and I started studying software engineering in 2010. I have been working commercially full time since 2014 and have been in various positions from graduate developer to tech lead to solution architect.
I'm a full stack developer with a lot of experience in C# and Javascript but my passion is for mobile development; specifically native iOS development and cross platform using React Native.

I always have many things on the go and am always trying out a new side hustle and failing at it; perhaps you can learn from my mistakes!

Please like and subscribe if you enjoyed this video and want to see more like it!
Have any suggestions on topics you would like to learn more about? Please suggest them in the comments... I would love to help you out while doing a bit of learning myself!

// PRODUCTS USED
I use the following products in the creation of my videos:

Boya MM1 Microphone - https://amzn.to/3m6kif7
A reasonable quality and reasonably sturdy but cost effective microphone that can be used by both DSLR cameras, mobile phones and laptops

Canon 18-55mm Lens - https://amzn.to/3IwscFR
A kit lens but a decent quality lens for beginners getting used to a DSLR

Canon EOS Rebel T7 with 18-55mm Lens - https://amzn.to/3XZauAL
This is the kit I started with it includes the lens linked above and is a great starter camera.

I love Apple devices... These are the ones I use for my channel content creation:

Apple iPhone 13 - https://amzn.to/3KAUba4
A good all round phone, good for Apple development and recording videos with enough high quality features but at a cheaper price point than the pro versions.

Apple MacBook Pro - https://amzn.to/3KxrE5q
A nice portable computer for working from anywhere and perfect for iOS development

Apple iPad Air - https://amzn.to/3xU2k21
Really easy to use for graphic design if required for logos as part of my app development or editing the videos on the go.

Apple Pencil (2nd Generation) - https://amzn.to/3EBSwNS
For logo and icon design in Affinity Designer app for iPad

Logitech Folio Keyboard Touch - https://amzn.to/3XUYBM1
Adds keyboard and touchpad to iPad Air, making it easier to use for writing code/eBooks etc. on the go!

DISCLAIMER: Links included in this description might be affiliate links. If you purchase a product or service with the links that I provide I may receive a small commission. There is no additional charge to you! Thank you for supporting my channel so I can continue to provide you with free content each week!

//CONTACT:
Please contact me at: [email protected]

//CRAVING MORE:
You can find links to all my different sites and social media over on Linktree: https://linktr.ee/misscoding


Watch video React Context for React Native - How to Access Data From Further Down the Component Tree online without registration, duration hours minute second in high quality. This video was added by user MissCoding 03 April 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 466 once and liked it 17 people.