You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After upgrading to Version 4 of baobab-react, whenever trying to use this.context.tree for the higher-order component, it gives an error reading property of undefined. This is occurring in a React Native project.
For the simplest example, I used the one you have in the documentation for higher-order components...
index.js
import React, { Component } from 'react';
import { AppRegistry } from 'react-native';
import { root } from 'baobab-react/higher-order';
import state from './state';
import { SafeAreaView, View } from 'react-native';
import List from './List';
// Creating our top-level component
class App extends Component {
render() {
return (
<SafeAreaView>
<View style={{ margin: 25 }}>
<List />
</View>
</SafeAreaView>);
}
}
// Let's bind the component to the tree through the `root` higher-order component
AppRegistry.registerComponent('BaobabTest', () => root(state, App));
List.js
import React, { Component } from 'react';
import { branch } from 'baobab-react/higher-order';
import PropTypes from 'baobab-react/prop-types';
import { Text, View } from 'react-native';
class List extends Component {
render() {
// Thanks to the branch, our colors will be passed as props to the component
const colors = this.props.colors;
// Show me the colors through context
console.log("Show me the colors!: ", this.context.tree.get(['colors']));
function renderItem(color) {
return <Text key={color}>{color}</Text>;
}
return <View>{colors.map(renderItem)}</View>;
}
}
List.contextTypes = {
tree: PropTypes.baobab
};
// Branching the component by mapping the desired data to cursors
export default branch({
colors: ['colors']
}, List);
The following error occurs in the console.log above. When downgrading to baoba-react V3 all works, but it doesn't let us take advantage of the new Hooks!
Thanks!
The text was updated successfully, but these errors were encountered:
After upgrading to Version 4 of baobab-react, whenever trying to use this.context.tree for the higher-order component, it gives an error reading property of undefined. This is occurring in a React Native project.
For the simplest example, I used the one you have in the documentation for higher-order components...
index.js
List.js
The following error occurs in the console.log above. When downgrading to baoba-react V3 all works, but it doesn't let us take advantage of the new Hooks!
Thanks!
The text was updated successfully, but these errors were encountered: