Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
React Native with Flumpt
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
TouchableHighlight,
View
} from 'react-native';
import {withFlux, dispatchable} from 'flumpt'
@dispatchable
class CounterIncrement extends Component {
onClick(e) {
console.log('click');
this.context.dispatch('increment')
}
render() {
return <TouchableHighlight onPress={this.onClick.bind(this)}><Text>+1</Text></TouchableHighlight>
}
}
@withFlux((update, on) => {
on('increment', () => {
update(state => {
return {count: state.count + 1}
})
})
}, {count: 0})
export default class FlumptExample extends Component {
render() {
return (
<View style={styles.container}>
<Text>{this.props.count}</Text>
<CounterIncrement/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
AppRegistry.registerComponent('FlumptExample', () => FlumptExample);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.