Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to call this.props.dispatch from within function #17

Open
mlevkovsky opened this issue Jun 3, 2016 · 0 comments
Open

How to call this.props.dispatch from within function #17

mlevkovsky opened this issue Jun 3, 2016 · 0 comments

Comments

@mlevkovsky
Copy link

mlevkovsky commented Jun 3, 2016

Hey @aksonov ,
first of great library! I will preface this with that I am a bit of a noob with react-native.

I was wondering how I would achieve calling the dispatch from within a function in my component.

import React, {Component} from 'react';
import {StyleSheet,Text,TouchableHighlight,View} from 'react-native';
import {Actions} from 'react-native-redux-router';

class Activity extends React.Component{
    propTypes: {
        style: View.propTypes.style
    }
    _onButtonPress(){
        return this.props.dispatch(Actions.activity);
    }
    render() {
        return (
            <TouchableHighlight style={this.props.style} onPress={()=>this._onButtonPress()}>
                <Text>Activity</Text>
            </TouchableHighlight>
        );
    }
}
export default (Activity);

If I try to do this I get "Actions must be plain object" error, naturally since Actions.activity is a function.

Thanks in advance.

@mlevkovsky mlevkovsky changed the title How call this.props.dispatch from within function How to call this.props.dispatch from within function Jun 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant