Simple React Router Example – Dan Buda – Medium

Simple React Router Example  #router #reactjs #react #reactjs

  • One of the things I love about React is how easy it is to make components and bring them all together.We’ll need to import a few things from React React Router Router to be able to make it all work.
  • And in our Link tags, we’ve included a to= and a path name that will be used in our Router code.So now for the Router:We use ReactDOM.render to tell our app how the navigation all fits together.
  • First, we want to use browserHistory in the main Router tag, and give our Router a starting point:So our App component, which will house our other components, is set up as the parent route that will use the path of just “/”.
  • Now we can add our Home component using IndexRoute to tell our Router that Home should load first upon getting to the site.The Home component/route is set up inside the App route because we want to set it as a child of App.
  • And now we can add our 2 link pages to the router:They are also added as children of the App component.

Just the basics of using React Router (version 2.8.1 — v4 just came out and I’ll monkey with that soon). So you can use React Router to handle all of your navigation, and once getting used to it, it…
Continue reading “Simple React Router Example – Dan Buda – Medium”

React Gotchas – Angularity

#ReactJS also has its gotchas:

  • Please enable JavaScript to view the comments powered by Disqus.
  • If you’re using JSX (and most people are), the components you write must begin with an uppercase letter.
  • setState ({ name : ‘Joe’ }, function () { // called after state has been updated // and the component has been re-rendered });
  • The means using names like UserList and Menu and SubmitButton , and not using names like userList , menu , and submitButton .
  • They’ll also get called whenever props change – so if you absolutely want to respond only to state changes, use the callback approach.

Read the full article, click here.


@ReactiveConf: “#ReactJS also has its gotchas:”


Beware these few mistakes that can trip you up.


React Gotchas – Angularity

React Gotchas

#Reactjs Gotchas interesting read

  • If you’re using JSX (and most people are), the components you write must begin with an uppercase letter.
  • They’ll also get called whenever props change – so if you absolutely want to respond only to state changes, use the callback approach.
  • setState({name: ‘ Joe’ }, function () { // called after state has been updated // and the component has been re-rendered });
  • The means using names like UserList and Menu and SubmitButton , and not using names like userList , menu , and submitButton .
  • Another alternative is to use the componentWillUpdate or componentDidUpdate lifecycle hooks, which will be called immediately before and after rendering in response to your state change.

Read the full article, click here.


@devlife411: “#Reactjs Gotchas interesting read”


React Gotchas; Author: Dave Ceddia; Updated: 4 Jul 2016; Section: Client side scripting; Chapter: Web Development; Updated: 4 Jul 2016


React Gotchas

Thinking in React

Thinking in @reactjs with a bunch of @jsfiddle examples –

  • Use the props to filter the rows in ProductTable and set the values of the form fields in SearchBar .
  • Step 1: Break the UI into a component hierarchy #
  • Find a common owner component (a single component above all the components that need the state in the hierarchy).
  • If you’re familiar with the concept of state , don’t use state at all to build this static version.
  • If you can’t find a component where it makes sense to own the state, create a new component simply for holding the state and add it somewhere in the hierarchy above the common owner component.

Read the full article, click here.


@oskar: “Thinking in @reactjs with a bunch of @jsfiddle examples –”


React is, in my opinion, the premier way to build big, fast Web apps with JavaScript. It has scaled very well for us at Facebook and Instagram.


Thinking in React