React Native Modal w/ Redux Delay in Toggling
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
add a comment |
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
I would suggest using Redux for you business logic state, and keeping the UI state like in this case simple withthis.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
add a comment |
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
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
react-native react-redux
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 withthis.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
add a comment |
I would suggest using Redux for you business logic state, and keeping the UI state like in this case simple withthis.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
add a comment |
1 Answer
1
active
oldest
votes
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
add a comment |
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
add a comment |
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
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
answered Jan 23 at 13:49
Vince GonzalesVince Gonzales
75110
75110
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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