What I learned from creating my first React app

ellereeeee
Jun 24, 2018 · 5 min read
Image for post
Image for post
animating stuff with react-transition-group

Read the React docs

If you’re just starting to learn React, start with the official docs. As far as docs go, the React ones are easy to understand and provide lots of examples.

Know JavaScript well, or be ready to learn

Look at this short code-snippet:

class Counter extends React.Component {
constructor(props) {
super(props)
this.state = {count: 0}
this.handleClick = this.handleClick.bind(this)
}

Think in React

Design your app into a wireframe or mockup and break it down into components. This will make the coding process much smoother.

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

Check the console for errors

I made a big mistake in my code, and I would’ve caught it if I checked the console for errors. You should always be doing this regardless of what language or framework you’re coding in.

./src/components/PomodoroTimer.jsx
Line 17: Do not mutate state directly. Use setState() react/no-direct-mutation-state
Line 21: Do not mutate state directly. Use setState() react/no-direct-mutation-state
handleIncrementTime = () => {
this.setState({ state: (this.state.time += 300000) });
};
handleDecrementTime = () => {
if (this.state.time > 300000) {
this.setState({ time: (this.state.time -= 300000) });
}
};
handleIncrementTime = () =>
this.setState(prevState => ({ time: (prevState.time + 300000) }));
handleDecrementTime = () => {
if (this.state.time > 300000) {
this.setState(prevState => ({ time: (prevState.time - 300000) }));
}
};

TL;DR

  1. If you’re learning React, start with the React docs.
  2. Know JavaScript well, or be ready to learn.
  3. Take time planning your app. Break down your UI into components and consider where state will live.
  4. Check the console for errors.

freeCodeCamp.org

This is no longer updated.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store