React-Native Redux pass data from component to store












1















I am actually new in redux, I started to discover it and understand its logic. I have a question in my mind that, is it possible to make api calls inside of components and pass the responses to store?



Because as I understand we can make API calls by triggering actions with action creators, but can I do make calls in component and when I get results am I able to pass it to reducer and store without using action creators?



How its possible, can someone give me a small example of it, if my question is logical?










share|improve this question























  • without using action creators - you mean without actions? The whole point of Redux is that you dispatch an action with its payload and then store handles it as needed. Without using actions you could easily lose control of your store as you use async operations like API calls

    – Julius Dzidzevičius
    Nov 16 '18 at 7:22






  • 1





    You can make your API call inside your component, and use action and reducer for just passing the result. That's possible even if not the best practice. Is that what you want?

    – Faruk Yazıcı
    Nov 16 '18 at 7:24











  • Yes @FarukYazıcı. Why its not the best practice, whats different if API call happens inside of component or in action component? Can you give me an example how I could do that

    – Berke
    Nov 16 '18 at 8:43
















1















I am actually new in redux, I started to discover it and understand its logic. I have a question in my mind that, is it possible to make api calls inside of components and pass the responses to store?



Because as I understand we can make API calls by triggering actions with action creators, but can I do make calls in component and when I get results am I able to pass it to reducer and store without using action creators?



How its possible, can someone give me a small example of it, if my question is logical?










share|improve this question























  • without using action creators - you mean without actions? The whole point of Redux is that you dispatch an action with its payload and then store handles it as needed. Without using actions you could easily lose control of your store as you use async operations like API calls

    – Julius Dzidzevičius
    Nov 16 '18 at 7:22






  • 1





    You can make your API call inside your component, and use action and reducer for just passing the result. That's possible even if not the best practice. Is that what you want?

    – Faruk Yazıcı
    Nov 16 '18 at 7:24











  • Yes @FarukYazıcı. Why its not the best practice, whats different if API call happens inside of component or in action component? Can you give me an example how I could do that

    – Berke
    Nov 16 '18 at 8:43














1












1








1








I am actually new in redux, I started to discover it and understand its logic. I have a question in my mind that, is it possible to make api calls inside of components and pass the responses to store?



Because as I understand we can make API calls by triggering actions with action creators, but can I do make calls in component and when I get results am I able to pass it to reducer and store without using action creators?



How its possible, can someone give me a small example of it, if my question is logical?










share|improve this question














I am actually new in redux, I started to discover it and understand its logic. I have a question in my mind that, is it possible to make api calls inside of components and pass the responses to store?



Because as I understand we can make API calls by triggering actions with action creators, but can I do make calls in component and when I get results am I able to pass it to reducer and store without using action creators?



How its possible, can someone give me a small example of it, if my question is logical?







reactjs react-native react-redux






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 16 '18 at 7:00









BerkeBerke

147214




147214













  • without using action creators - you mean without actions? The whole point of Redux is that you dispatch an action with its payload and then store handles it as needed. Without using actions you could easily lose control of your store as you use async operations like API calls

    – Julius Dzidzevičius
    Nov 16 '18 at 7:22






  • 1





    You can make your API call inside your component, and use action and reducer for just passing the result. That's possible even if not the best practice. Is that what you want?

    – Faruk Yazıcı
    Nov 16 '18 at 7:24











  • Yes @FarukYazıcı. Why its not the best practice, whats different if API call happens inside of component or in action component? Can you give me an example how I could do that

    – Berke
    Nov 16 '18 at 8:43



















  • without using action creators - you mean without actions? The whole point of Redux is that you dispatch an action with its payload and then store handles it as needed. Without using actions you could easily lose control of your store as you use async operations like API calls

    – Julius Dzidzevičius
    Nov 16 '18 at 7:22






  • 1





    You can make your API call inside your component, and use action and reducer for just passing the result. That's possible even if not the best practice. Is that what you want?

    – Faruk Yazıcı
    Nov 16 '18 at 7:24











  • Yes @FarukYazıcı. Why its not the best practice, whats different if API call happens inside of component or in action component? Can you give me an example how I could do that

    – Berke
    Nov 16 '18 at 8:43

















without using action creators - you mean without actions? The whole point of Redux is that you dispatch an action with its payload and then store handles it as needed. Without using actions you could easily lose control of your store as you use async operations like API calls

– Julius Dzidzevičius
Nov 16 '18 at 7:22





without using action creators - you mean without actions? The whole point of Redux is that you dispatch an action with its payload and then store handles it as needed. Without using actions you could easily lose control of your store as you use async operations like API calls

– Julius Dzidzevičius
Nov 16 '18 at 7:22




1




1





You can make your API call inside your component, and use action and reducer for just passing the result. That's possible even if not the best practice. Is that what you want?

– Faruk Yazıcı
Nov 16 '18 at 7:24





You can make your API call inside your component, and use action and reducer for just passing the result. That's possible even if not the best practice. Is that what you want?

– Faruk Yazıcı
Nov 16 '18 at 7:24













Yes @FarukYazıcı. Why its not the best practice, whats different if API call happens inside of component or in action component? Can you give me an example how I could do that

– Berke
Nov 16 '18 at 8:43





Yes @FarukYazıcı. Why its not the best practice, whats different if API call happens inside of component or in action component? Can you give me an example how I could do that

– Berke
Nov 16 '18 at 8:43












0






active

oldest

votes











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%2f53332908%2freact-native-redux-pass-data-from-component-to-store%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















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%2f53332908%2freact-native-redux-pass-data-from-component-to-store%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

Bressuire

Vorschmack

Quarantine