computerjazz / reactnavigationredux Goto Github PK
View Code? Open in Web Editor NEWExample app for connecting react navigation state with redux
Example app for connecting react navigation state with redux
I've follow the react-navigation redux integration and also check your sample code but still the listener not working. here is my code ...
App.js
const App = () => (
<Provider store={store}>
<AppWithNavigationState />
</Provider>
);
...
AppWithNavigationState.js
const mapStateToProps = state => ({
nav: state.nav,
});
@connect(mapStateToProps)
export default class AppWithNavigationState extends Component {
onBackPress = () => {
const { dispatch, nav } = this.props;
if (nav.index == 0) {
return false;
}
dispatch(NavigationActions.back());
return true;
};
render() {
const { dispatch, nav } = this.props;
return (
<SafeAreaView style={{ flex: 1 }}>
<AppNavigator
navigation={addNavigationHelpers({
dispatch,
state: nav,
addListener,
})}
/>
</SafeAreaView>
);
}
}
SearchScreen.js
const mapStateToProps = store => ({
list: store.getList,
});
@connect(mapStateToProps)
export default class SearchScreen extends Component {
static navigationOptions = ({ navigation }) =>
// const { params = {} } = navigation.state;
({
// header: (
// <FilterCalendar
// timeText={params.timeText}
// previousDateOnPress={params.previousDateOnPress}
// nextDateOnPress={params.nextDateOnPress}
// />
// ),
tabBarLabel: constants.SEARCH_TAB_TITLE,
});
state = {
currentDate: new Date(),
timeText: gregorianToJalai(new Date()),
skip: this.props.list.skip,
};
componentDidMount() {
this.makeRemoteRequest(false, true);
this.updateNavigationParams();
this.subs = [
this.props.navigation.addListener('willFocus', () => console.log('will focus')),
this.props.navigation.addListener('willBlur', () => console.log('will blur')),
this.props.navigation.addListener('didFocus', () => console.log('did focus')),
this.props.navigation.addListener('didBlur', () => console.log('did blur')),
];
}
componentWillUnmount() {
this.subs.forEach(s => s.remove());
}
...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.