Friday, September 8, 2017

React for Angular Developers

This article is for developers who are familiar with Angular 1.x and would like to learn more about React. We’ll look at the different approaches they take to building rich web applications, the overlapping functionality and the gaps that React doesn’t attempt to fill. After reading, you’ll have an understanding of the problems that React […]

Continue reading %React for Angular Developers%


by Mark Brown via SitePoint

#351: Package Manager Yarn Reaches Version 1.0

This week's JavaScript newsRead this e-mail on the Web
JavaScript Weekly
Issue 351 — September 8, 2017
The Yarn JavaScript package manager is now used by 175,000 projects on GitHub and responsible for 3 billion package downloads per month.
Facebook Code

A developer at Google shares a sneak preview of a tool (still in alpha) for more efficient builds of large Angular apps.
Alex Eagle

Google, Inc.
Connect with Chrome engineers and other leading developers for a two-day exploration of building beautiful and performant experiences at the Yerba Buena Center for the Arts on 23-24 October.
Google, Inc.   Sponsor

Oriented around Hapi, React, React Router v4, Redux, Postgres, and NGINX. GitHub repo.
Tane Piper

Ditch console.log debugging once and for all by learning to use breakpoints to debug code within the DevTools.
Brandon Morelli

If ultra-light alternatives to things like React appeal to you, innerself is worth checking out, even if just for the explanation of how it works.
Staś Małolepszy

Jobs Supported by Hired.com

Can't find the right job? Want companies to apply to you? Try Hired.com.

In Brief

confs.tech: An Up-to-Date List of Upcoming JS Conferences news

Quokka.js Live JavaScript Scratchpad Now Available for Atom news
Artem Govorov

Using terminal to view test results is a productivity killer 
It's like browsing the web in a text-based browser. We deliver test results in realtime to your editor.
Wallaby.js  Sponsor

Building a Simple Notes Manager with Vue.js tutorial
Yanis Triandaphilov

Building a Mini Card Game with Polymer 3.0 Preview tutorial
Jecelyn Yeen

The Curious Case of 'null >= 0' tutorial
A trip down one of JavaScript’s many rabbit holes. “It makes sense, honestly”, says the author.
Abinav Seelan

Don’t Be Afraid of Headless Chrome: Why and How to Use It for Ember Testing tutorial
Jen Weber

Building TDD RESTful APIs with Koa 2, Mocha and Chai tutorial node
Valentino Gagliardi

It’s OK to Not Use Yarn opinion
“Is there something wrong with using Yarn? Yes, there is, if you don’t need it.”
David Gilbertson

Angular vs. React vs. Vue: A 2017 Comparison opinion
An informative take on how to choose the best framework for your next project.
Jens Neuhaus

The Wonderful World of Webpack opinion
Explains the reasoning behind Webpack, and what makes it more than a mere module bundler.
Jack Histon

Micro Frontends: Extending Microservice Ideas to Frontend Development opinion
Micro Frontends

How I Convinced Our CTO to Switch From CoffeeScript to ES6 story
Zach Schneider

#1 Way to Detect, Diagnose and Defeat Errors 🏆 tools
Rollbar detects when code breaks in real-time. Get stack trace and diagnostic data to defeat errors.
ROLLBAR  Sponsor

AssemblyScript: A Subset of TypeScript That Compiles to WebAssembly tools

Fastify: Fast and Low Overhead Web Framework for Node.js code node

LookForward.js: Easily Create Smooth Transitions Between Pages code

vue-accordion-menu: A Simple Vue 2 Accordion Menu Component code
Wesley Chang

React-PDF: Display PDF Files in Your React App code
Demo here.
Wojciech Maj

Rythm.js: A JavaScript Library That Makes Your Page 'Dance' code
Demo here.
Benjamin Plouzennec

Realtime updates on web and mobile that just work 
Pusher  Sponsor

Curated by Peter Cooper and published by Cooperpress.

Like this? You may also enjoy: FrontEnd Focus : Node Weekly : React Status

Stop getting JavaScript Weekly : Change email address : Read this issue on the Web

© Cooperpress Ltd. Fairfield Enterprise Centre, Lincoln Way, Louth, LN11 0LS, UK


by via JavaScript Weekly

How Social Media Stars Convert Influence Into Cash [video]

Ever wonder how social media stars turn their online celebrity into cash? Well, we've got you covered.

[ This is a content summary only. Visit our website http://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Web Desk via Digital Information World

Higher Order Components: A React Application Design Pattern

In this article we will discuss how to use Higher Order Components to keep your React applications tidy, well structured and easy to maintain. We’ll discuss how pure functions keep code clean and how these same principles can be applied to React components.

Pure Functions

A function is considered pure if it adheres to the following properties:

  • All the data it deals with are declared as arguments
  • It does not mutate data it was given or any other data (these are often referred to as side effects).
  • Given the same input, it will always return the same output.

For example, the add function below is pure:

function add(x, y) {
  return x + y;
}

However, the function badAdd below is impure:

var y = 2;
function badAdd(x) {  
  return x + y;
}

This function is not pure because it references data that it hasn’t directly been given. As a result, it’s possible to call this function with the same input and get different output:

var y = 2;
badAdd(3) // 5
y = 3;
badAdd(3) // 6

To read more about pure functions you can read “An introduction to reasonably pure programming” by Mark Brown.

Whilst pure functions are very useful, and make debugging and testing an application much easier, occasionally you will need to create impure functions that have side effects, or modify the behavior of an existing function that you are unable to access directly (a function from a library, for example). To enable this we need to look at higher order functions.

Higher Order Functions

A higher order function is a function that when called, returns another function. Often they also take a function as an argument, but this is not required for a function to be considered higher order.

Let’s say we have our add function from above, and we want to write some code so that when we call it we log the result to the console before returning the result. We’re unable to edit the add function, so instead we can create a new function:

function addAndLog(x, y) {  
  var result = add(x, y);
  console.log('Result', result);
  return result;
}

We decide that logging results of functions is useful, and now we want to do the same with a subtract function. Rather than duplicate the above, we could write a higher order function that can take a function and return a new function that calls the given function and logs the result before then returning it:

function logAndReturn(func) {  
  return function() {  
    var args = Array.prototype.slice.call(arguments);
    var result = func.apply(null, args);
    console.log('Result', result);
    return result;
  }
}

Now we can take this function and use it to add logging to add and subtract:

var addAndLog = logAndReturn(add);
addAndLog(4, 4) // 8 is returned, ‘Result 8’ is logged

var subtractAndLog = logAndReturn(subtract);
subtractAndLog(4, 3) // 1 is returned, ‘Result 1’ is logged;

logAndReturn is a HOF because it takes a function as its argument and returns a new function that we can call. These are really useful for wrapping existing functions that you can’t change in behavior. For more information on this, check M. David Green’s article “Higher-Order Functions in JavaScript which goes into much more detail on the subject.

Additionally you can check out this CodePen, which shows the above code in action.

Higher Order Components

Moving into React land, we can use the same logic as above to take existing React components and give them some extra behaviours.

In this section we're going to use React Router, the de facto routing solution for React. If you'd like to get started with the library I highly recommend the React Router Tutorial on GitHub.

React Router’s Link component

React Router provides a <Link> component that is used to link between pages in a React application. One of the properties that this <Link> component takes is activeClassName. When a <Link> has this property and it is currently active (the user is on a URL that the link points to), the component will be given this class, enabling the developer to style it.

This is a really useful feature, and in our hypothetical application we decide that we always want to use this property. However, after doing so we quickly discover that this is making all our <Link> components very verbose:

<Link to="/" activeClassName="active-link">Home</Link>
<Link to="/about" activeClassName="active-link">About</Link>
<Link to="/contact" activeClassName="active-link">Contact</Link>

Notice that we are having to repeat the class name property every time. Not only does this make our components verbose, it also means that if we decide to change the class name we’ve got to do it in a lot of places.

Continue reading %Higher Order Components: A React Application Design Pattern%


by Jack Franklin via SitePoint

Put Your View Controllers on a Diet With MVVM

Testing Components in Angular Using Jasmine: Part 2, Services

5 Types of Visual Content You Need for Your Marketing Campaign [Infographic]

If you are about to embark on a content marketing campaign, you need to know exactly what will stimulate online growth and engagement. Text-based content is always going to be an integral part of marketing, but to really set yourself apart in the digital era, visual content must play a pivotal role...

[ This is a content summary only. Visit our website http://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Web Desk via Digital Information World