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.
- Host: GitHub
- URL: https://github.com/sandeshnaroju/react-native-dbcontext
- Owner: sandeshnaroju
- Created: 2020-05-10T05:45:11.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-26T19:57:46.000Z (almost 3 years ago)
- Last Synced: 2025-02-16T07:41:20.554Z (10 months ago)
- Topics: react-context-api, react-native, react-native-library
- Language: Java
- Size: 1.93 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
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.