WatermelonDB: withDatabase is returning object instead of function - using RN 0.60.5 & watermelon 0.14.0
I have wrapped Root component in Database Provider.
<DatabaseProvider database={database}> <App/> </DatabaseProvider>
I am trying to access the database inside my component
`const enhance = withDatabase(withObservables([‘members’], ({ members, database }) => { console.log(“ddsdmndsf”, database) // database is undefined return {
users: database.collections.get('members').query().observe(),
members
}
}))`
const EnhancedLang = enhance(LanguageSelectionScreen) // export default LanguageSelectionScreen;
export default class LanguageSelScreen extends Component { constructor(props){ super(props); this.state = {}; console.log(“inside languge components”, EnhancedLang) // Returns an object } render() { return ( <EnhancedLang /> ); } }
EnhancedLang returns an Object
{$$typeof: Symbol(react.element), type: {…}, key: null, ref: null, props: {…}, …} $$typeof: Symbol(react.element) key: null props: {children: ƒ} ref: null type: {$$typeof: Symbol(react.context), _context: {…}, _calculateChangedBits: null, …} _owner: null _store: {validated: false} _self: null _source: null __proto__: Object
It throws the error.
@radex : Can you please help me to figure out where I am going wrong.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 1
- Comments: 16 (6 by maintainers)
I experience the same problem but am not using babel-plugin-module-resolver, with:
Simply can’t get the HOC to work 😢
This is one example: https://github.com/barbalex/vermehrung/blob/watermelondb/src/components/Data/Herkunft/DataProviderHOC.js
Am now using
useStateanduseEffectand plain rxjs methods:I am actually finding this quite powerful. Would there be a reason not to do it like this? (I am new to observables)