Keep getting 'Object is not a function' error












0















I keep getting an error 'Object is not a function ...' in for my Main.js file. How can it be fixed and what I'm doing wrong? Here is the screenshot of the error:enter image description here. Also here is my code for my Main.js file:



import React from 'react';
import { StyleSheet, Text, Image, View, Vibrate } from 'react-native';

import Settings from './Settings';
import Profile from './Profile';

import {connect} from 'react-redux';
import {saveProfile, saveSettings} from '../redux/actions';

class Main extends React.Component {

componentWillMount() {
if (!this.props.avatarUrl) {
this.props.saveProfile(this.props.location);
}
}

render() {
return (
<View style={styles.container, bgColor}>
<Image
source={this.props.avatarUrl}
style={{width: 300, height: 300}}
/>
<Text>{this.props.name}</Text>
<Text>{this.props.phone}</Text>
<Text>{this.props.email}</Text>
<Settings />
</View>
);
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});

export default saveProfile (
connect(
state=>state.location,
{saveProfile}
)
)(Main);


My goal is to display the information saved in redux.










share|improve this question


















  • 1





    Have you tried instead connect( state=>state.location, {saveProfile} )(saveProfile (Main))?

    – Shawn Andrews
    Nov 28 '18 at 0:32











  • It gives out Syntax error SyntaxError: /Users/arina/Desktop/mobapp/comps/Main.js: Unexpected token, expected "," (47:20)

    – Arina
    Nov 28 '18 at 0:35








  • 1





    In your connect(...) please replace {saveProfile} with null. Will it compile now?

    – Shawn Andrews
    Nov 28 '18 at 0:47






  • 1





    Remove the saveProfile in it as well, so export default connect( state=>state.location, null )(Main)

    – Shawn Andrews
    Nov 28 '18 at 0:52






  • 1





    in that case you can leave out the second parameter and just connect( state=>state.location)(Main)

    – Shawn Andrews
    Nov 28 '18 at 1:13
















0















I keep getting an error 'Object is not a function ...' in for my Main.js file. How can it be fixed and what I'm doing wrong? Here is the screenshot of the error:enter image description here. Also here is my code for my Main.js file:



import React from 'react';
import { StyleSheet, Text, Image, View, Vibrate } from 'react-native';

import Settings from './Settings';
import Profile from './Profile';

import {connect} from 'react-redux';
import {saveProfile, saveSettings} from '../redux/actions';

class Main extends React.Component {

componentWillMount() {
if (!this.props.avatarUrl) {
this.props.saveProfile(this.props.location);
}
}

render() {
return (
<View style={styles.container, bgColor}>
<Image
source={this.props.avatarUrl}
style={{width: 300, height: 300}}
/>
<Text>{this.props.name}</Text>
<Text>{this.props.phone}</Text>
<Text>{this.props.email}</Text>
<Settings />
</View>
);
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});

export default saveProfile (
connect(
state=>state.location,
{saveProfile}
)
)(Main);


My goal is to display the information saved in redux.










share|improve this question


















  • 1





    Have you tried instead connect( state=>state.location, {saveProfile} )(saveProfile (Main))?

    – Shawn Andrews
    Nov 28 '18 at 0:32











  • It gives out Syntax error SyntaxError: /Users/arina/Desktop/mobapp/comps/Main.js: Unexpected token, expected "," (47:20)

    – Arina
    Nov 28 '18 at 0:35








  • 1





    In your connect(...) please replace {saveProfile} with null. Will it compile now?

    – Shawn Andrews
    Nov 28 '18 at 0:47






  • 1





    Remove the saveProfile in it as well, so export default connect( state=>state.location, null )(Main)

    – Shawn Andrews
    Nov 28 '18 at 0:52






  • 1





    in that case you can leave out the second parameter and just connect( state=>state.location)(Main)

    – Shawn Andrews
    Nov 28 '18 at 1:13














0












0








0








I keep getting an error 'Object is not a function ...' in for my Main.js file. How can it be fixed and what I'm doing wrong? Here is the screenshot of the error:enter image description here. Also here is my code for my Main.js file:



import React from 'react';
import { StyleSheet, Text, Image, View, Vibrate } from 'react-native';

import Settings from './Settings';
import Profile from './Profile';

import {connect} from 'react-redux';
import {saveProfile, saveSettings} from '../redux/actions';

class Main extends React.Component {

componentWillMount() {
if (!this.props.avatarUrl) {
this.props.saveProfile(this.props.location);
}
}

render() {
return (
<View style={styles.container, bgColor}>
<Image
source={this.props.avatarUrl}
style={{width: 300, height: 300}}
/>
<Text>{this.props.name}</Text>
<Text>{this.props.phone}</Text>
<Text>{this.props.email}</Text>
<Settings />
</View>
);
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});

export default saveProfile (
connect(
state=>state.location,
{saveProfile}
)
)(Main);


My goal is to display the information saved in redux.










share|improve this question














I keep getting an error 'Object is not a function ...' in for my Main.js file. How can it be fixed and what I'm doing wrong? Here is the screenshot of the error:enter image description here. Also here is my code for my Main.js file:



import React from 'react';
import { StyleSheet, Text, Image, View, Vibrate } from 'react-native';

import Settings from './Settings';
import Profile from './Profile';

import {connect} from 'react-redux';
import {saveProfile, saveSettings} from '../redux/actions';

class Main extends React.Component {

componentWillMount() {
if (!this.props.avatarUrl) {
this.props.saveProfile(this.props.location);
}
}

render() {
return (
<View style={styles.container, bgColor}>
<Image
source={this.props.avatarUrl}
style={{width: 300, height: 300}}
/>
<Text>{this.props.name}</Text>
<Text>{this.props.phone}</Text>
<Text>{this.props.email}</Text>
<Settings />
</View>
);
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});

export default saveProfile (
connect(
state=>state.location,
{saveProfile}
)
)(Main);


My goal is to display the information saved in redux.







reactjs react-native redux react-redux redux-thunk






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 28 '18 at 0:29









ArinaArina

269




269








  • 1





    Have you tried instead connect( state=>state.location, {saveProfile} )(saveProfile (Main))?

    – Shawn Andrews
    Nov 28 '18 at 0:32











  • It gives out Syntax error SyntaxError: /Users/arina/Desktop/mobapp/comps/Main.js: Unexpected token, expected "," (47:20)

    – Arina
    Nov 28 '18 at 0:35








  • 1





    In your connect(...) please replace {saveProfile} with null. Will it compile now?

    – Shawn Andrews
    Nov 28 '18 at 0:47






  • 1





    Remove the saveProfile in it as well, so export default connect( state=>state.location, null )(Main)

    – Shawn Andrews
    Nov 28 '18 at 0:52






  • 1





    in that case you can leave out the second parameter and just connect( state=>state.location)(Main)

    – Shawn Andrews
    Nov 28 '18 at 1:13














  • 1





    Have you tried instead connect( state=>state.location, {saveProfile} )(saveProfile (Main))?

    – Shawn Andrews
    Nov 28 '18 at 0:32











  • It gives out Syntax error SyntaxError: /Users/arina/Desktop/mobapp/comps/Main.js: Unexpected token, expected "," (47:20)

    – Arina
    Nov 28 '18 at 0:35








  • 1





    In your connect(...) please replace {saveProfile} with null. Will it compile now?

    – Shawn Andrews
    Nov 28 '18 at 0:47






  • 1





    Remove the saveProfile in it as well, so export default connect( state=>state.location, null )(Main)

    – Shawn Andrews
    Nov 28 '18 at 0:52






  • 1





    in that case you can leave out the second parameter and just connect( state=>state.location)(Main)

    – Shawn Andrews
    Nov 28 '18 at 1:13








1




1





Have you tried instead connect( state=>state.location, {saveProfile} )(saveProfile (Main))?

– Shawn Andrews
Nov 28 '18 at 0:32





Have you tried instead connect( state=>state.location, {saveProfile} )(saveProfile (Main))?

– Shawn Andrews
Nov 28 '18 at 0:32













It gives out Syntax error SyntaxError: /Users/arina/Desktop/mobapp/comps/Main.js: Unexpected token, expected "," (47:20)

– Arina
Nov 28 '18 at 0:35







It gives out Syntax error SyntaxError: /Users/arina/Desktop/mobapp/comps/Main.js: Unexpected token, expected "," (47:20)

– Arina
Nov 28 '18 at 0:35






1




1





In your connect(...) please replace {saveProfile} with null. Will it compile now?

– Shawn Andrews
Nov 28 '18 at 0:47





In your connect(...) please replace {saveProfile} with null. Will it compile now?

– Shawn Andrews
Nov 28 '18 at 0:47




1




1





Remove the saveProfile in it as well, so export default connect( state=>state.location, null )(Main)

– Shawn Andrews
Nov 28 '18 at 0:52





Remove the saveProfile in it as well, so export default connect( state=>state.location, null )(Main)

– Shawn Andrews
Nov 28 '18 at 0:52




1




1





in that case you can leave out the second parameter and just connect( state=>state.location)(Main)

– Shawn Andrews
Nov 28 '18 at 1:13





in that case you can leave out the second parameter and just connect( state=>state.location)(Main)

– Shawn Andrews
Nov 28 '18 at 1:13












2 Answers
2






active

oldest

votes


















1














your problem is the way you are exporting your main module and the way you connect redux to make uses of the props, I give you the following example to give you an idea of ​​the use of redux...
`



actions.js



import * as ACTIONS from './types';

export const reset = () => {
return { type: ACTIONS.RESET_STATE };
};

export const saveProfile = profile => {
return { type: ACTIONS.SAVE_PROFILE, payload: profile };
};

export const saveSettings = settings => {
return { type: ACTIONS.SAVE_SETTINGS, payload: settings };
};


reducer.js



import * as ACTIONS from './../actions/types';

const INITIAL_STATE = {
profile: 0,
settings: 0
};

export default (state = INITIAL_STATE, action) => {
switch (action.type) {
case ACTIONS.RESET_STATE:
return { ...INITIAL_STATE };
case ACTIONS.SAVE_PROFILE:
return { ...state, profile: action.profile };
case ACTIONS.SAVE_SETTINGS:
return { ...state, settings: action.settings };
default:
return state;
}
};


index.js /combinereducers



import { combineReducers } from 'redux';

import reducers from './reducer.js';

export default combineReducers({
reducer: reducers
});


and usage into you Main class



import { saveProfile, saveSettings } from './../redux/actions/index.js';

class Main extends Component {
constructor(props) {
super(props);
this.state = {
saveProfile: this.props.profile,
saveSettings: this.props.settings
};
{.....



.....}

const mapStateToProps = ({ reducers }) => {
const { profile, settings } = reducers;

return { profile, settings };
};

export default connect(mapStateToProps, { saveProfile, saveSettings })(Main);


I hope it helps you






share|improve this answer































    0














    It looks like the error is coming from your export default statement at the bottom. This particular export looks like it may have a syntax error, so double-check how that's structured in the example you're using.






    share|improve this answer
























    • I've followed the example as it is, but it's not working for me properly.

      – Arina
      Nov 28 '18 at 0:59











    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53510335%2fkeep-getting-object-is-not-a-function-error%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    your problem is the way you are exporting your main module and the way you connect redux to make uses of the props, I give you the following example to give you an idea of ​​the use of redux...
    `



    actions.js



    import * as ACTIONS from './types';

    export const reset = () => {
    return { type: ACTIONS.RESET_STATE };
    };

    export const saveProfile = profile => {
    return { type: ACTIONS.SAVE_PROFILE, payload: profile };
    };

    export const saveSettings = settings => {
    return { type: ACTIONS.SAVE_SETTINGS, payload: settings };
    };


    reducer.js



    import * as ACTIONS from './../actions/types';

    const INITIAL_STATE = {
    profile: 0,
    settings: 0
    };

    export default (state = INITIAL_STATE, action) => {
    switch (action.type) {
    case ACTIONS.RESET_STATE:
    return { ...INITIAL_STATE };
    case ACTIONS.SAVE_PROFILE:
    return { ...state, profile: action.profile };
    case ACTIONS.SAVE_SETTINGS:
    return { ...state, settings: action.settings };
    default:
    return state;
    }
    };


    index.js /combinereducers



    import { combineReducers } from 'redux';

    import reducers from './reducer.js';

    export default combineReducers({
    reducer: reducers
    });


    and usage into you Main class



    import { saveProfile, saveSettings } from './../redux/actions/index.js';

    class Main extends Component {
    constructor(props) {
    super(props);
    this.state = {
    saveProfile: this.props.profile,
    saveSettings: this.props.settings
    };
    {.....



    .....}

    const mapStateToProps = ({ reducers }) => {
    const { profile, settings } = reducers;

    return { profile, settings };
    };

    export default connect(mapStateToProps, { saveProfile, saveSettings })(Main);


    I hope it helps you






    share|improve this answer




























      1














      your problem is the way you are exporting your main module and the way you connect redux to make uses of the props, I give you the following example to give you an idea of ​​the use of redux...
      `



      actions.js



      import * as ACTIONS from './types';

      export const reset = () => {
      return { type: ACTIONS.RESET_STATE };
      };

      export const saveProfile = profile => {
      return { type: ACTIONS.SAVE_PROFILE, payload: profile };
      };

      export const saveSettings = settings => {
      return { type: ACTIONS.SAVE_SETTINGS, payload: settings };
      };


      reducer.js



      import * as ACTIONS from './../actions/types';

      const INITIAL_STATE = {
      profile: 0,
      settings: 0
      };

      export default (state = INITIAL_STATE, action) => {
      switch (action.type) {
      case ACTIONS.RESET_STATE:
      return { ...INITIAL_STATE };
      case ACTIONS.SAVE_PROFILE:
      return { ...state, profile: action.profile };
      case ACTIONS.SAVE_SETTINGS:
      return { ...state, settings: action.settings };
      default:
      return state;
      }
      };


      index.js /combinereducers



      import { combineReducers } from 'redux';

      import reducers from './reducer.js';

      export default combineReducers({
      reducer: reducers
      });


      and usage into you Main class



      import { saveProfile, saveSettings } from './../redux/actions/index.js';

      class Main extends Component {
      constructor(props) {
      super(props);
      this.state = {
      saveProfile: this.props.profile,
      saveSettings: this.props.settings
      };
      {.....



      .....}

      const mapStateToProps = ({ reducers }) => {
      const { profile, settings } = reducers;

      return { profile, settings };
      };

      export default connect(mapStateToProps, { saveProfile, saveSettings })(Main);


      I hope it helps you






      share|improve this answer


























        1












        1








        1







        your problem is the way you are exporting your main module and the way you connect redux to make uses of the props, I give you the following example to give you an idea of ​​the use of redux...
        `



        actions.js



        import * as ACTIONS from './types';

        export const reset = () => {
        return { type: ACTIONS.RESET_STATE };
        };

        export const saveProfile = profile => {
        return { type: ACTIONS.SAVE_PROFILE, payload: profile };
        };

        export const saveSettings = settings => {
        return { type: ACTIONS.SAVE_SETTINGS, payload: settings };
        };


        reducer.js



        import * as ACTIONS from './../actions/types';

        const INITIAL_STATE = {
        profile: 0,
        settings: 0
        };

        export default (state = INITIAL_STATE, action) => {
        switch (action.type) {
        case ACTIONS.RESET_STATE:
        return { ...INITIAL_STATE };
        case ACTIONS.SAVE_PROFILE:
        return { ...state, profile: action.profile };
        case ACTIONS.SAVE_SETTINGS:
        return { ...state, settings: action.settings };
        default:
        return state;
        }
        };


        index.js /combinereducers



        import { combineReducers } from 'redux';

        import reducers from './reducer.js';

        export default combineReducers({
        reducer: reducers
        });


        and usage into you Main class



        import { saveProfile, saveSettings } from './../redux/actions/index.js';

        class Main extends Component {
        constructor(props) {
        super(props);
        this.state = {
        saveProfile: this.props.profile,
        saveSettings: this.props.settings
        };
        {.....



        .....}

        const mapStateToProps = ({ reducers }) => {
        const { profile, settings } = reducers;

        return { profile, settings };
        };

        export default connect(mapStateToProps, { saveProfile, saveSettings })(Main);


        I hope it helps you






        share|improve this answer













        your problem is the way you are exporting your main module and the way you connect redux to make uses of the props, I give you the following example to give you an idea of ​​the use of redux...
        `



        actions.js



        import * as ACTIONS from './types';

        export const reset = () => {
        return { type: ACTIONS.RESET_STATE };
        };

        export const saveProfile = profile => {
        return { type: ACTIONS.SAVE_PROFILE, payload: profile };
        };

        export const saveSettings = settings => {
        return { type: ACTIONS.SAVE_SETTINGS, payload: settings };
        };


        reducer.js



        import * as ACTIONS from './../actions/types';

        const INITIAL_STATE = {
        profile: 0,
        settings: 0
        };

        export default (state = INITIAL_STATE, action) => {
        switch (action.type) {
        case ACTIONS.RESET_STATE:
        return { ...INITIAL_STATE };
        case ACTIONS.SAVE_PROFILE:
        return { ...state, profile: action.profile };
        case ACTIONS.SAVE_SETTINGS:
        return { ...state, settings: action.settings };
        default:
        return state;
        }
        };


        index.js /combinereducers



        import { combineReducers } from 'redux';

        import reducers from './reducer.js';

        export default combineReducers({
        reducer: reducers
        });


        and usage into you Main class



        import { saveProfile, saveSettings } from './../redux/actions/index.js';

        class Main extends Component {
        constructor(props) {
        super(props);
        this.state = {
        saveProfile: this.props.profile,
        saveSettings: this.props.settings
        };
        {.....



        .....}

        const mapStateToProps = ({ reducers }) => {
        const { profile, settings } = reducers;

        return { profile, settings };
        };

        export default connect(mapStateToProps, { saveProfile, saveSettings })(Main);


        I hope it helps you







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 28 '18 at 2:44









        Daniel EncinaDaniel Encina

        1114




        1114

























            0














            It looks like the error is coming from your export default statement at the bottom. This particular export looks like it may have a syntax error, so double-check how that's structured in the example you're using.






            share|improve this answer
























            • I've followed the example as it is, but it's not working for me properly.

              – Arina
              Nov 28 '18 at 0:59
















            0














            It looks like the error is coming from your export default statement at the bottom. This particular export looks like it may have a syntax error, so double-check how that's structured in the example you're using.






            share|improve this answer
























            • I've followed the example as it is, but it's not working for me properly.

              – Arina
              Nov 28 '18 at 0:59














            0












            0








            0







            It looks like the error is coming from your export default statement at the bottom. This particular export looks like it may have a syntax error, so double-check how that's structured in the example you're using.






            share|improve this answer













            It looks like the error is coming from your export default statement at the bottom. This particular export looks like it may have a syntax error, so double-check how that's structured in the example you're using.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 28 '18 at 0:43









            miles_bmiles_b

            14018




            14018













            • I've followed the example as it is, but it's not working for me properly.

              – Arina
              Nov 28 '18 at 0:59



















            • I've followed the example as it is, but it's not working for me properly.

              – Arina
              Nov 28 '18 at 0:59

















            I've followed the example as it is, but it's not working for me properly.

            – Arina
            Nov 28 '18 at 0:59





            I've followed the example as it is, but it's not working for me properly.

            – Arina
            Nov 28 '18 at 0:59


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53510335%2fkeep-getting-object-is-not-a-function-error%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

            Calculate evaluation metrics using cross_val_predict sklearn

            Insert data from modal to MySQL (multiple modal on website)