Skip to content

Instantly share code, notes, and snippets.

I work with React every single day. I try my best to follow various guides, discussions , videos, blog posts, personal learnings, etc in order to write good and maintainable code, yet I've rarely had to dig into the framework like I've had to for other types of frameworks and libraries in order to achieve the same goal. I really appreciate this about React. After just learning the foundations, like props and state, classes vs stateless components, and a little about lifecycle methods you are already on your way to writing a decent React app.

But I couldn't help but look at a typical component and wonder what the hell was going on. I mean, it all pretty much looks like vanilla JavaScript. Well, apart from JSX, nothing looks super out of the ordinary... right? So where is all this React magic coming from? How do these lifecycle methods get called? Where is setState defined?

I recently rebuilt my own Redux/React-Redux and I

class App {
render() {
return React.createElement('div', null, this.props.message)
}
}
ReactDOM.render(React.createElement(App, {message: "this is the result of calling this.props.message"}),
document.getElementById('root'))

Introduction to Sinatra

1. What is the purpose of the server file (routing)?

Contains all the verbs and routing, to give back the info that is requested.

2. How do you pass variables into the views?

  Through instance variables 
  setting :locals

3. How can we interpolate ruby into a view (html)?