Create-react-app: document how to add redux (or an example)

Created on 11 Sep 2016  Â·  6Comments  Â·  Source: facebook/create-react-app

Redux is an essential part of my react development. I like create-react-app, but now I need to find a way to add in redux. Do I "eject" and then add redux or ...? At that point it is more helpful [for me] to use another boiler plate project project. Put another way, create-react-app lowers the barrier to starting a react project, but it does not lower the barrier to starting a react-redux project.

Most helpful comment

Also, to clarify, this project is not meant to provide the "boilerplate" code for your app. We think that it is important that you write app code yourself, and understand the libraries you are using, and their APIs.

This project exists to make build process easy. This means you don't have to think about configuring Babel, Webpack or ESLint. Everything needed so you can write JSX and ES6 and have a good development experience.

However it doesn't make choices about which runtime libraries you use, or how you structure your app. So it's not an opinionated "starter kit".

Such starter kits could be built on top of Create React App. In fact all examples in Redux repo use it, so you might want to check them out.

All 6 comments

CRA only handles the build process. Redux, or any React components, are regular dependencies. To install them, you run npm install. They have no relation to build process so you use them the same way you used them before.

Also, to clarify, this project is not meant to provide the "boilerplate" code for your app. We think that it is important that you write app code yourself, and understand the libraries you are using, and their APIs.

This project exists to make build process easy. This means you don't have to think about configuring Babel, Webpack or ESLint. Everything needed so you can write JSX and ES6 and have a good development experience.

However it doesn't make choices about which runtime libraries you use, or how you structure your app. So it's not an opinionated "starter kit".

Such starter kits could be built on top of Create React App. In fact all examples in Redux repo use it, so you might want to check them out.

I did not know you had ported the redux examples to CRA, that is very helpful - thanks. I'm finding it hard to grasp the conceptual model of CRA. Not boilerplate, not starter kit, abstracts away webpack and babel complexity, yet build system doesn't seem right either. Having it generate code, while good, is also a bit misleading if it is a build process. Not complaining, just thinking.

Well, tools like this weren't very popular before so I don't think we ever came up with a name. It does a few things:

  • Creates an empty project for you with a single component. In this case it's sensible to generate _some_ code so people don't have blank page syndrome. Especially important for beginners. Fiddling with a component that already works is easier than trying to create your first component from scratch. We don't include something like Redux because it is pretty opinionated, and you can build React apps without it just fine.
  • Hides development dependencies behind a single development dependency. I would call this a "tool facade" if this makes sense. It tries to unite several tools into a cohesive experience without burdening you with configuration.
  • Running "eject" moves all build dependencies and configuration into your project so it becomes more like a build boilerplate, but you can do it at any time, even when you already have an app written.

So yeah, it doesn't cleanly fit those roles, but that's precisely because we think those roles are problematic and didn't work well, and we wanted to try something different.

names:

 - react virtual build environment

 - react integrated tool set

 - react federated build tools.

create-react-app --add_redux --add_whatever --no_app (only generates
index.js) --add api_server

Just speculations, not even suggestions.

:-)

Terry

On 9/12/16 5:55 AM, Dan Abramov wrote:

Well, tools like this weren't very popular before so I don't think we
ever came up with a name. It does a few things:

  • Creates an empty project for you with a single component. In this
    case it's sensible to generate /some/ code so people don't have
    blank page syndrome. Especially important for beginners. Fiddling
    with a component that already works is easier than trying to
    create your first component from scratch. We don't include
    something like Redux because it is pretty opinionated, and you can
    build React apps without it just fine.
  • Hides development dependencies behind a single development
    dependency. I would call this a "tool facade" if this makes sense.
    It tries to unite several tools into a cohesive experience without
    burdening you with configuration.
  • Running "eject" moves all build dependencies and configuration
    into your project so it becomes more like a build boilerplate, but
    you can do it at any time, even when you already have an app written.

So yeah, it doesn't cleanly fit those roles, but that's precisely
because we think those roles are problematic and didn't work well, and
we wanted to try something different.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/facebookincubator/create-react-app/issues/630#issuecomment-246301376,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAC5Im28mVe6UQQpxhZW3KOkA2u863Iiks5qpSGFgaJpZM4J6ESN.

For now, I feel this is out of scope so closing.
People who just start learning React generally don’t need Redux, and those who do should already be comfortable with installing libraries from npm by that point.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fson picture fson  Â·  3Comments

alleroux picture alleroux  Â·  3Comments

AlexeyRyashencev picture AlexeyRyashencev  Â·  3Comments

rdamian3 picture rdamian3  Â·  3Comments

oltsa picture oltsa  Â·  3Comments