Adding an entrypoint
React applications are composed of a hierarchy of components that are rendered at the root. Our application entrypoint should render this root component.
I tend to not test-drive my entrypoint, because any test that loads our entire application can become quite brittle as we add in more and more dependencies into it. In Section 4, Acceptance Testing with BDD, we'll look at using acceptance tests to write some tests that will cover the entrypoint.
Since we aren't test-driving it, we follow a couple of general rules:
-
Keep it as brief as possible
-
Only use it to instantiate dependencies for your root component, and to call ReactDOM.render.
Before we run our app, we'll need some sample data. Create a file named src/sampleData.js ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access