Basic Start of a React App I'm new to react and am building a basic react app and have just built a basic area where navigation links render on a page but wonder whether my current start could be optimised - for example, I wonder whether an area like this:
render() {
    return (
        &lt;Root navLinks={this.state.navLinks}&gt;&lt;/Root&gt;
    );
  } 

Could be changed to something like this:
render() {
    return (
        &lt;Root&gt;
           &lt;NavLinks navLinks={this.state.navLinks} /&gt;
        &lt;/Root&gt;
    );
  } 

And I wonder about other aspects of the app such as do I need an App.js file or index.js file and could have one rather than the other?
Any quick basic beginner advice would be much appreciated. The code can be better found in this Stackblitz demo or below:
App.js:
import React, {Component} from &quot;react&quot;;
import {navLinks} from &quot;./components/nav-links&quot;;
import Root from &quot;./components/Root&quot;;

export default class App extends Component {
  constructor() {
    super();

    this.state = {
      navLinks: navLinks
    }
  }

  render() {
    return (
        &lt;Root navLinks={this.state.navLinks}&gt;&lt;/Root&gt;
    );
  } 
}

index.js:
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

ReactDOM.render(
  &lt;App /&gt;,
  document.getElementById('root')
);

/components/Root.js:
import React from &quot;react&quot;;
import NavMenu from &quot;./nav-menu&quot;;
import BodyCode from &quot;./body-code&quot;;

export default class Root extends React.Component {
    render() {
        return (
            &lt;div id=&quot;container&quot;&gt;
                &lt;div id=&quot;header&quot;&gt;
                    &lt;NavMenu navLinks={this.props.navLinks} /&gt;
                &lt;/div&gt;
                &lt;div id=&quot;body&quot;&gt;
                    &lt;BodyCode /&gt;
                &lt;/div&gt;
            &lt;/div&gt;
        )
    }
}

/components/body-code.js:
import React from &quot;react&quot;;

export default class bodyCode extends React.Component {
    constructor(props) {
        super(props);
        this.state = {isToggleOn: true}; // boolean for event listener alternative
    
        // This binding is necessary to make `this` work in the callback
        this.handleClick = this.handleClick.bind(this);
      } // bind is saying make the ‘this’ keyword bind(this), where the 2nd ‘this’ is the ‘this’ of the constructor
    
      handleClick() {
        this.setState(state =&gt; ({
          isToggleOn: !state.isToggleOn // sets state to the opposite of whatever it is
        }));
      }
      
  render() {
    return (
      &lt;div&gt;
          &lt;p&gt;some body text&lt;/p&gt;
          &lt;button onClick={this.handleClick}&gt;
            {this.state.isToggleOn ? 'ON' : 'OFF'}
            &lt;/button&gt;
      &lt;/div&gt;
    )
  }
}

/components/nav-links.js:
export const navLinks = [
  {
    name: &quot;home&quot;,
    href: &quot;/&quot;
  },
  {
    name: &quot;subs&quot;,
    href: &quot;/subs&quot;
  }
];

/components/nav-menu.js:
import React from &quot;react&quot;;

export default class navBar extends React.Component {
  render() {
    return (
      this.props.navLinks.map((link) =&gt; &lt;a href={link.href} key = {link.href} &gt; {link.name} &lt;/a&gt;)
    )
  }
}
Questions

Should Root take props or wrap children components?

&lt;Root navLinks={this.state.navLinks}&gt;&lt;/Root&gt;

vs
&lt;Root&gt;
  &lt;NavLinks navLinks={this.state.navLinks} /&gt;
&lt;/Root&gt;

I think this primarily comes down to the purpose of Root. If it is a general purpose wrapper container component, then the latter pattern makes sense. I.E. it is providing the layout but no actual UI, this works well. If on the other hand it isn't very generalizable, i.e. it is more single purpose, then passing it props is preferred. I understand this doesn't sound like an answer, but like many things in javascript, there's no clear, hard line between them and this could also simply come down to personal preference/opinion.

Do I need an App.js file or index.js file and could have one rather than the other?

Again, these both exist by convention, but you could easily merge the two if you so desired. The distinction basically comes down to separation of concerns. index.js is primarily concerned with rendering the application into the DOM whereas App.js is primarily concerned with being the root application container. This is typically where redux stores &amp; providers, react contexts &amp; providers (well, all &quot;providers&quot; in general), root routers/navigation, theming, etc, etc... would/could reside and provide functionality to the app.
Code Review
App.js

For such simple components (no state updates or no state, no lifecycle functions, etc..) it is recommended to instead use functional components
There is no compelling reason to store the static link data in react state, just pass it directly to props
navLinks isn't a component so it probably shouldn't be stored in that directory, better suited for a utility directory or similar
Root doesn't wrap any children components so it can be self-closed

Suggestion
import React from &quot;react&quot;;
import { navLinks } from &quot;./components/nav-links&quot;;
import Root from &quot;./components/Root&quot;;

export const App = () =&gt; &lt;Root navLinks={navLinks} /&gt;;

/components/Root.js

Many of the same comments as for App.js
If the element ids are actually used (CSS, testing) then keep them, otherwise they just clutter the JSX
BodyCode is already wrapped in a div, so the div here is extraneous and helps increase clutter in the DOM

Suggestion
import React from &quot;react&quot;;
import NavMenu from &quot;./nav-menu&quot;;
import BodyCode from &quot;./body-code&quot;;

export const Root = ({ navLinks }) =&gt; (
  &lt;div&gt;
    &lt;div&gt;
      &lt;NavMenu navLinks={navLinks} /&gt;
    &lt;/div&gt;
    &lt;BodyCode /&gt;
  &lt;/div&gt;
);

/components/body-code.js

By convention react component names are PascalCased
handleClick can be defined as an arrow function, which would make binding this to it in the constructor unnecessary
Great job on using a functional state update to toggle the isToggleOn state value
While not a necessity, the constructor can be removed and state defined as a class property
Also not a necessity, this component is still simple enough and doesn't utilize any lifecycle functions that it is also a good candidate for conversion to functional component

Class-based suggestion
import React, { Component } from &quot;react&quot;;

export class BodyCode extends Component {
  state = {
    isToggleOn: true,
  };

  handleClick = () =&gt; this.setState(
    prevState =&gt; ({ isToggleOn: !prevState.isToggleOn })
  );

  render() {
    return (
      &lt;div&gt;
        &lt;p&gt;some body text&lt;/p&gt;
        &lt;button onClick={this.handleClick}&gt;
          {this.state.isToggleOn ? 'ON' : 'OFF'}
        &lt;/button&gt;
      &lt;/div&gt;
    )
  }
}

Functional component suggestion
import React, { useState } from &quot;react&quot;;

export const BodyCode = () =&gt; {
  const [isToggleOn, setIsToggleOn] = useState(true);

  const handleClick = () =&gt; setIsToggleOn(on =&gt; !on);

  return (
    &lt;div&gt;
      &lt;p&gt;some body text&lt;/p&gt;
      &lt;button onClick={handleClick}&gt;
        {isToggleOn ? 'ON' : 'OFF'}
      &lt;/button&gt;
    &lt;/div&gt;
  );
};

/components/nav-menu.js

Should follow react component naming convention
Simple and should probably be converted to functional component

Suggestion
import React from &quot;react&quot;;

export const NavBar = ({ navLinks }) =&gt; navLinks.map(link =&gt; (
  &lt;a key={link.href} href={link.href}&gt;
    {link.name}
  &lt;/a&gt;
));

Other Suggestions
Use a routing/navigation solution versus using anchor (&lt;a /&gt;) tags as these actually reload the app. These typically provide all the functionality of links and navigating around your app by manipulating the browser's history stack but won't reload the page between navigations.
react-router/react-router-dom is a common routing solution. The idea being you define Routes, wrapped in a Router/Switch, to render each &quot;page&quot; of your app, and instead of anchor tags a Link is used to go to a specified path.
A sample router in BodyCode
import { BrowserRouter as Router, Route } from 'react-router-dom';

...

&lt;div&gt;
  &lt;p&gt;some body text&lt;/p&gt;
  &lt;button onClick={this.handleClick}&gt;
    {isToggleOn ? 'ON' : 'OFF'}
  &lt;/button&gt;
  &lt;Router&gt;
    &lt;Route path=&quot;/subs&quot; component={Subs} /&gt;
    &lt;Route path=&quot;/&quot; component={Home} /&gt;
  &lt;/Router&gt;
&lt;/div&gt;

NavMenu
import { Link } from 'react-router-dom';

...

navLinks.map(link =&gt; (
  &lt;Link key={link.href} to={link.href}&gt;
    {link.name}
  &lt;/Link&gt;
))