Don’t eject your Create React App

Last updated 168 days ago by Adam Laycock

react

If you found yourself on this page because you want to eject your Create React App project, the details you’re looking for are at the bottom of this article.

But before you jump down, I hope you consider reviewing this article because ejecting can introduce much more complexity to your project than you might anticipate. Before you commit to your irreversible decision to eject, let me propose a few alternatives.

Why are you ejecting?

There are 3 primary reasons why someone might choose to eject and each reason has either drawbacks or alternatives that should first be investigated.

  • “I can manage the build on my own” or “I want full control over my project.”
  • “Create-React-App is missing a feature that I need, so I’m going to add it myself.”
  • “I’m curious about the build process and want to learn how it works.”

“I can manage the build on my own” or “I want full control over my project”

I’ll admit that the first CRA project I created, I immediately ejected. My naïve assumption was that managing my own build process is something experts did and I assumed I was experienced enough to handle it.

“I’m a good programmer, I can manage my own build tools, I just need a headstart from Create-React-App.”

In reality, experts do everything they can to avoid additional configuration, tools, and code. Before you eject, ask yourself, “Do I want to build something using React or do I want to fight with picky build tools when things stop working?”

Don’t eject until you have a specific reason to do so. If you feel that you have a good reason to eject at a later date, circle back to this article and reevaluate your position. Ejecting is a one-way process and makes your configuration more complex; why burn that bridge before you’ve even used it?

If you’re being thoughtful enough to learn more about ejecting before jumping in, also be thoughtful enough to consider that CRA’s “sane defaults” might work for you, at least for now.

“Create-React-App is missing a feature that I need, so I’m going to add it myself”

This is a great reason to eject. It’s the reason most people do so. However, before you eject, take the time to ensure you aren’t making extra work for yourself or repeating the work someone else has done previously.

Is this something the Create-React-App team has already discussed?

There are thousands of issues filed in the Create-React-App repo, and chances are someone has already addressed your concern. Explore the existing discussions around the topic; you might find a solution or alternative already exists. If it hasn’t been discussed yet, consider filing an issue or making a PR. Thoughtful input is always appreciated.

Has someone built this already?

A nice feature of the CRA sub-package react-scripts is that it can easily be forked and modified. The resulting forked configuration can then be used by your project. Try exploring some existing forks of react-scripts to see if they include the features you want, but without having the maintenance burden of managing your own configuration files. React-super-scripts is an example of one alternative that includes decorators, babel stage-0 features, CSS, SASS, and LESS modules:

Read full Article