JavaScript Programmatically change react component being displayed programmatically change route react,programmatically change route react router,react

I'm trying to have a page that switches out which component is rendered based off of a pair of navigation buttons. The page is set up like this

ReactDOM.render(<Logo/>, document.getElementById('logo'));
ReactDOM.render(<Upload/>, document.getElementById('main'));
ReactDOM.render(<NavButtons/>, document.getElementById('nav_buttons'))
ReactDOM.render(<Footer />, document.getElementById('footer'));

The <Upload/> component is the one I wish to cycle out. So when the user pressed the 'next' navigation button a different component would then be loaded on the page.

How do you go about this? Am I attacking this problem correctly? I am new to react so trying to figure out the best way to utilize it.

Ended up using both answers below for different use cases. Both work to accomplish this though.

Answer:1

Your use case can be achieved by changing the internal state of the parent container on user clicks and rendering different child components by checking which component to render based on the state value.

Since, you are new to react, I don't even know if u get the point. Go through react docs about state, props and lifecycles before starting to code in react.

https://reactjs.org/docs/state-and-lifecycle.html

Answer:2

I am new to ReactJS. I am stuck in one problem. I get textbox value from calling API which has predefined value. but When I try to edit its value then it is not letting me to edit. class ...

I am new to ReactJS. I am stuck in one problem. I get textbox value from calling API which has predefined value. but When I try to edit its value then it is not letting me to edit. class ...

I want to change image and that trigger an image update. This is for example http://jsbin.com/kuluyike/3/edit?html,js,output <div id="colorPicker"> <img v-attr="src:color" alt="{{...

I want to change image and that trigger an image update. This is for example http://jsbin.com/kuluyike/3/edit?html,js,output <div id="colorPicker"> <img v-attr="src:color" alt="{{...

  1. jquery when radio selected
  2. when radio button selected
  3. when radio button is selected jquery
  4. when radio button is selected javascript

I have multiple sliders which is defined by document.querySelectorAll( '.js-slider' ); on tooltips.format I would like to insert a label above the value, which is defined on the current slide object ...

I have multiple sliders which is defined by document.querySelectorAll( '.js-slider' ); on tooltips.format I would like to insert a label above the value, which is defined on the current slide object ...

How can i return array position of each object in an array. code let targets = [1.2, 2.3, 3.5]; let targetUpdatedOn = [2018-07-06, 2018-07-06, 2018-07-06]; let liveCoinPrice = 1.3; let targets_hit =...

How can i return array position of each object in an array. code let targets = [1.2, 2.3, 3.5]; let targetUpdatedOn = [2018-07-06, 2018-07-06, 2018-07-06]; let liveCoinPrice = 1.3; let targets_hit =...