Container Components and Stateless Functional Components in React – Zsolt Nagy

  • Let’s introduce functional components: – – has become a function with a argument, returning the return value of the method of the original implementation.
  • Implications of the structure of stateless functional components: – – In the introduction, I mentioned that stateless functional components come with performance benefits.
  • Typically, container components have the following properties: – – The rule of thumb for choosing the appropriate syntax for React components is the following: – – then it is advised to use stateless functional components.
  • Let’s put theory into practice, and transform all the stateless component in our chat application into functional components.
  • Reviewing the conditions for modeling a component with a function, we can see that there is absolutely nothing preventing us from creating a functional equivalent of the class.

We will now introduce another way to define simple components. You will not only write less code, but you will also benefit from performance optimizations done by React. Let’s introduce functional components:
Continue reading “Container Components and Stateless Functional Components in React – Zsolt Nagy”

From native to React Native

  • After developing mobile applications for more than eight months, I had the opportunity of joining a project that was being developed using React Native, an open source JavaScript library that, according to its documentation, lets you build mobile apps using only JavaScript.
  • React Native it’s a very new technology announced on the beginning of 2015 – just a couple years ago – where the main objective is to allow the development of mobile apps using the same design as React, letting you compose a rich mobile UI from declarative components.
  • There were a lot of things that I enjoyed about developing a React Native app, like the flexibility that you can get out of JavaScript after get used on how it works and the core concepts of React.
  • I had a really great time working with React Native and after developing the base components I felt that creating new screens was even faster than coding on native languages.
  • Another great factor that makes it easy to develop apps using React Native is the fact that the JavaScript community is huge, this means lots and lots of knowledge shared on Stack Overflow.

React Native main objective is to allow the development of mobile apps using the same design as React.
Continue reading “From native to React Native”

JavaScript: The beauty of arrow functions – LeanJS – Medium

JavaScript: The beauty of arrow functions  #react #arrowfunctions #es6 #javascript #reactjs

  • JavaScript: The beauty of arrow functionsArrow functions are an awesome ES6 language feature for a number of reasons, but we believe there are 3 key reasons they really shine:They are more conciseThey allow for implicit returnsThey get their “this” value from the context, meaning it comes from the callerLet’s look at some ES5 vs ES6 code:In the above code example we compare the ES5 and ES6 way of grabbing some values from an array of objects.More ConciseThe most striking thing is the amount of code, less code means less probability of introducing errors.
  • Secondly it’s obvious that our arrow function has improved readability here, it’s also more declarative.
  • Being concise and declarative with code is especially important when working in teams, it saves time and improves outcomes.Implicit returnsThe ability to return values implicitly builds upon the first point, we no longer need to add extra syntax such as the {} and return keyword if they are not needed.
  • So context is simply the one who is calling the function.If this isn’t clear, have a play with the code yourself here: why is getting the “this” value from the context useful?Before we had to bind our functions explicitly to make sure they had the right “this” value:We can of course continue doing this, but now we have a more concise way of doing the same thing:Summing upUsing arrow functions allows us to use a more concise and declarative syntax while eliminating the need for us to bind them explicitly.
  • There are of course a few more things to know about arrow functions which are beyond the scope of this post.

Arrow functions are an awesome ES6 language feature for a number of reasons, but we believe there are 3 key reasons they really shine: In the above code example we compare the ES5 and ES6 way of…
Continue reading “JavaScript: The beauty of arrow functions – LeanJS – Medium”

Container Components and Stateless Functional Components in React – Zsolt Nagy

  • Let’s introduce functional components:

    has become a function with a argument, returning the return value of the method of the original implementation.

  • Implications of the structure of stateless functional components:

    In the introduction, I mentioned that stateless functional components come with performance benefits.

  • Typically, container components have the following properties:

    The rule of thumb for choosing the appropriate syntax for React components is the following:

    then it is advised to use stateless functional components.

  • Let’s put theory into practice, and transform all the stateless component in our chat application into functional components.
  • Reviewing the conditions for modeling a component with a function, we can see that there is absolutely nothing preventing us from creating a functional equivalent of the class.

We will now introduce another way to define simple components. You will not only write less code, but you will also benefit from performance optimizations done by React. Let’s introduce functional components:
Continue reading “Container Components and Stateless Functional Components in React – Zsolt Nagy”

Functional JavaScript for Lazy Developers (Like Me) — SitePoint

Functional #JavaScript for lazy developers:  #ReactJS

  • Functional JavaScript, a Remedy for the Lazy
    One of the core concepts that has driven my quest for knowledge about programming techniques has always been my own laziness.
  • Higher Order Functions
    One of the things that makes JavaScript capable of handling functional programming techniques is the fact that it supports higher-order functions.
  • Pure Functions with No Side Effects
    Functional programming also brings with it some strong opinions about how functions should be written.
  • A pure function in functional programming is the ideal.
  • These days I don’t generally insist on functional techniques for all of my JavaScript code, but I usually find sprinkling in some functional fairy dust makes reasoning about every programming challenge more approachable.

Applying functional techniques improved my programs, problem-solving skills, process; my code was cleaner and easier to maintain — with less work.
Continue reading “Functional JavaScript for Lazy Developers (Like Me) — SitePoint”

Container Components and Stateless Functional Components in React – Zsolt Nagy

Container Components and Stateless Functional Components in #ReactJS:

  • Let’s introduce functional components:

    has become a function with a argument, returning the return value of the method of the original implementation.

  • Implications of the structure of stateless functional components:

    In the introduction, I mentioned that stateless functional components come with performance benefits.

  • Typically, container components have the following properties:

    The rule of thumb for choosing the appropriate syntax for React components is the following:

    then it is advised to use stateless functional components.

  • Let’s put theory into practice, and transform all the stateless component in our chat application into functional components.
  • Reviewing the conditions for modeling a component with a function, we can see that there is absolutely nothing preventing us from creating a functional equivalent of the class.

We will now introduce another way to define simple components. You will not only write less code, but you will also benefit from performance optimizations done by React. Let’s introduce functional components:
Continue reading “Container Components and Stateless Functional Components in React – Zsolt Nagy”