Skip to content

Instantly share code, notes, and snippets.

@rapPayne
Last active March 23, 2019 22:49
Show Gist options
  • Select an option

  • Save rapPayne/3119c0757583f4124a5c064f24f39cd1 to your computer and use it in GitHub Desktop.

Select an option

Save rapPayne/3119c0757583f4124a5c064f24f39cd1 to your computer and use it in GitHub Desktop.
React Native vs Flutter - React Native statefull component
import React, { Component } from 'react'; // <-- 1
import { Button, Image, SafeAreaView, ScrollView, Text, View } from 'react-native';
import { store } from './store/store'; // <-- 2
import { DatePicker } from './DatePicker'; // <-- 3
import { FilmBrief } from './FilmBrief'; // <-- 3
import { FilmDetails } from './FilmDetails'; // <-- 3
import { ShowingTimes } from './ShowingTimes'; // <-- 3
export class Landing extends Component { // <-- 4
constructor(props) { // <-- 5
super(props);
this.state = {...store.getState()}; // <-- 6
store.subscribe(() => this.setState(store.getState())); // <-- 6
}
componentDidMount() { // <-- 7
store.dispatch({type: "FETCH_FILMS"});
}
render() {
// This is where the subcomponents will be drawn. // <-- 8
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment