React Native Modal w/ Redux Delay in Toggling












2















I have a global button that is located in the root navigator and I also have a custom modal component that has its own reducer and actions. I am calling a toggle function inside the global button to toggle the modal, but when I compare the speed of the toggling on a modal that uses an ordinary state, it is much faster than with redux state. Why is this so?



Modal:



<Modal
visible={this.props.showCoinModal}
animationType="fade"
transparent={true}
onRequestClose={() => console.log('closed')}
>


Mapping:



const mapStateToProps = state => ({
showCoinModal: state.coinModal.showCoinModal
})

const mapDispatchToProps = dispatch => {
return {
onToggleCoinModal: () => dispatch(toggleCoinModal()),
}
}


Modal Reducer:



const initialState = {
showCoinModal: false
}

const coinModalData = (state = initialState, action) => {
switch (action.type) {
case TOGGLE_COIN_MODAL:
return {
...state,
showCoinModal: !state.showCoinModal
}
default:
return state
}
}









share|improve this question























  • I would suggest using Redux for you business logic state, and keeping the UI state like in this case simple with this.setState({...}).

    – romin21
    Jan 20 at 17:26











  • "this.state" is created with the component and stays inside a component hence setState is much faster as compared to redux which is handling the state globally,

    – Shabbir Haider
    Jan 23 at 5:00











  • I already figured out what's causing the delay, it's the middleware logger of redux, I jsut removed it and it's fast again

    – Vince Gonzales
    Jan 23 at 13:48
















2















I have a global button that is located in the root navigator and I also have a custom modal component that has its own reducer and actions. I am calling a toggle function inside the global button to toggle the modal, but when I compare the speed of the toggling on a modal that uses an ordinary state, it is much faster than with redux state. Why is this so?



Modal:



<Modal
visible={this.props.showCoinModal}
animationType="fade"
transparent={true}
onRequestClose={() => console.log('closed')}
>


Mapping:



const mapStateToProps = state => ({
showCoinModal: state.coinModal.showCoinModal
})

const mapDispatchToProps = dispatch => {
return {
onToggleCoinModal: () => dispatch(toggleCoinModal()),
}
}


Modal Reducer:



const initialState = {
showCoinModal: false
}

const coinModalData = (state = initialState, action) => {
switch (action.type) {
case TOGGLE_COIN_MODAL:
return {
...state,
showCoinModal: !state.showCoinModal
}
default:
return state
}
}









share|improve this question























  • I would suggest using Redux for you business logic state, and keeping the UI state like in this case simple with this.setState({...}).

    – romin21
    Jan 20 at 17:26











  • "this.state" is created with the component and stays inside a component hence setState is much faster as compared to redux which is handling the state globally,

    – Shabbir Haider
    Jan 23 at 5:00











  • I already figured out what's causing the delay, it's the middleware logger of redux, I jsut removed it and it's fast again

    – Vince Gonzales
    Jan 23 at 13:48














2












2








2








I have a global button that is located in the root navigator and I also have a custom modal component that has its own reducer and actions. I am calling a toggle function inside the global button to toggle the modal, but when I compare the speed of the toggling on a modal that uses an ordinary state, it is much faster than with redux state. Why is this so?



Modal:



<Modal
visible={this.props.showCoinModal}
animationType="fade"
transparent={true}
onRequestClose={() => console.log('closed')}
>


Mapping:



const mapStateToProps = state => ({
showCoinModal: state.coinModal.showCoinModal
})

const mapDispatchToProps = dispatch => {
return {
onToggleCoinModal: () => dispatch(toggleCoinModal()),
}
}


Modal Reducer:



const initialState = {
showCoinModal: false
}

const coinModalData = (state = initialState, action) => {
switch (action.type) {
case TOGGLE_COIN_MODAL:
return {
...state,
showCoinModal: !state.showCoinModal
}
default:
return state
}
}









share|improve this question














I have a global button that is located in the root navigator and I also have a custom modal component that has its own reducer and actions. I am calling a toggle function inside the global button to toggle the modal, but when I compare the speed of the toggling on a modal that uses an ordinary state, it is much faster than with redux state. Why is this so?



Modal:



<Modal
visible={this.props.showCoinModal}
animationType="fade"
transparent={true}
onRequestClose={() => console.log('closed')}
>


Mapping:



const mapStateToProps = state => ({
showCoinModal: state.coinModal.showCoinModal
})

const mapDispatchToProps = dispatch => {
return {
onToggleCoinModal: () => dispatch(toggleCoinModal()),
}
}


Modal Reducer:



const initialState = {
showCoinModal: false
}

const coinModalData = (state = initialState, action) => {
switch (action.type) {
case TOGGLE_COIN_MODAL:
return {
...state,
showCoinModal: !state.showCoinModal
}
default:
return state
}
}






react-native react-redux






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 14 at 16:47









Vince GonzalesVince Gonzales

75110




75110













  • I would suggest using Redux for you business logic state, and keeping the UI state like in this case simple with this.setState({...}).

    – romin21
    Jan 20 at 17:26











  • "this.state" is created with the component and stays inside a component hence setState is much faster as compared to redux which is handling the state globally,

    – Shabbir Haider
    Jan 23 at 5:00











  • I already figured out what's causing the delay, it's the middleware logger of redux, I jsut removed it and it's fast again

    – Vince Gonzales
    Jan 23 at 13:48



















  • I would suggest using Redux for you business logic state, and keeping the UI state like in this case simple with this.setState({...}).

    – romin21
    Jan 20 at 17:26











  • "this.state" is created with the component and stays inside a component hence setState is much faster as compared to redux which is handling the state globally,

    – Shabbir Haider
    Jan 23 at 5:00











  • I already figured out what's causing the delay, it's the middleware logger of redux, I jsut removed it and it's fast again

    – Vince Gonzales
    Jan 23 at 13:48

















I would suggest using Redux for you business logic state, and keeping the UI state like in this case simple with this.setState({...}).

– romin21
Jan 20 at 17:26





I would suggest using Redux for you business logic state, and keeping the UI state like in this case simple with this.setState({...}).

– romin21
Jan 20 at 17:26













"this.state" is created with the component and stays inside a component hence setState is much faster as compared to redux which is handling the state globally,

– Shabbir Haider
Jan 23 at 5:00





"this.state" is created with the component and stays inside a component hence setState is much faster as compared to redux which is handling the state globally,

– Shabbir Haider
Jan 23 at 5:00













I already figured out what's causing the delay, it's the middleware logger of redux, I jsut removed it and it's fast again

– Vince Gonzales
Jan 23 at 13:48





I already figured out what's causing the delay, it's the middleware logger of redux, I jsut removed it and it's fast again

– Vince Gonzales
Jan 23 at 13:48












1 Answer
1






active

oldest

votes


















1














I already figured out what's causing the delay, it's the middleware logger of redux, I just removed it and it's fast again






share|improve this answer























    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%2f54185779%2freact-native-modal-w-redux-delay-in-toggling%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    I already figured out what's causing the delay, it's the middleware logger of redux, I just removed it and it's fast again






    share|improve this answer




























      1














      I already figured out what's causing the delay, it's the middleware logger of redux, I just removed it and it's fast again






      share|improve this answer


























        1












        1








        1







        I already figured out what's causing the delay, it's the middleware logger of redux, I just removed it and it's fast again






        share|improve this answer













        I already figured out what's causing the delay, it's the middleware logger of redux, I just removed it and it's fast again







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 23 at 13:49









        Vince GonzalesVince Gonzales

        75110




        75110
































            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%2f54185779%2freact-native-modal-w-redux-delay-in-toggling%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

            Liquibase includeAll doesn't find base path

            How to use setInterval in EJS file?

            Petrus Granier-Deferre