An open API service indexing awesome lists of open source software.

https://github.com/sandeshnaroju/react-native-dbcontext

It is an example how child components in react native gets database reference from parent component using React Context API.
https://github.com/sandeshnaroju/react-native-dbcontext

react-context-api react-native react-native-library

Last synced: 8 months ago
JSON representation

It is an example how child components in react native gets database reference from parent component using React Context API.

Awesome Lists containing this project

README

          

# react-native-dbcontext
It is an example how all child components in react native gets database reference from parent component using React Context API.

### NOTE: ###
In this example, I have used watermelonDB, but you can use whatever database framework you want to use.

read the complete usage [here](https://www.naroju.com/how-to-use-react-context-to-pass-database-reference-to-child-components/)

### HOW TO USE:

1. Copy the db folder into your project, and Initialize your DB in the `DbProvider.js` file itself. And pass the value to `DbContext.Provider`.
2. In the parent component surround elements with `DbProvider`.
3. In the Child component you can either surround elements with `DbContext.Consumer` or use `this.context` to get the reference of database.