reactjs - How should I update a component and non-component from an AJAX call? -


sorry if question confusing getting started react. basically, looking start adding individual components existing website. currently, when page loads there couple of ajax requests update different parts of page jquery.

for example, make ajax request called every 30 seconds accountinfo , when returns response, update 2 separate parts of page, let's call them accountpanel , sidebar.

question #1

if create component accountpanel, should make ajax request when component mounts , continue use jquery update sidebar in there?

question #2

or better create components both , pass ajax response props?

reactdom.render(<accountpanel  />, document.getelementbyid('accountpanel')); reactdom.render(<sidebar />, document.getelementbyid('sidebar')); 

any appreciated :)

actually, think need state container. share state(in case accountinfo) between of components.

personally, recommend using redux. because container predictable.

in result code looks like:

//create redux store somehow  reactdom.render(<accountpanel  store = {resuxstore}/>, document.getelementbyid('accountpanel')); reactdom.render(<sidebar  store = {resuxstore}/>, document.getelementbyid('sidebar')); 

Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

Ansible warning on jinja2 braces on when -