All You Need To Know About CSS-in-JS – Hacker Noon

  • CSS-in-JS attached a style tag on top of the DOM while inline styles just attached the properties to the DOM node.Why does this matter?Not all CSS features can be aliased with JavaScript event handlers , many pseudo selectors aren’t possible, styling the html and body tags isn’t supported etc.With CSS-in-JS, you…
  • Some libraries (like jss, styled-components) even add support for neat, non-CSS-native features like nesting!Brilliant article going in depth on how they’re different.“Just write the darn CSS in CSS and be done with it.”Yes — while that’s the case for how it’s been done for a long-long time — the challenge is modern web is…
  • Shout-out to Vue for solving this problem beautifully even tho Vues styles have no access to components state.Here’s Bob Ross painting rocks to cool down the tension 😄What are the benefits of using CSS-in-JS?
  • CSS-in-JS leverages the full power of the JavaScript ecosystem to enhance CSS.“True rules isolation” — Scoped selectors are not enough.
  • JSS generates unique class names by default when it compiles JSON representation to CSS.Vendor Prefixing —The CSS rules are automatically vendor prefixed, so you don’t have to think about it.Code sharing — Easily share constants and functions between JS and CSS.Only the styles which are currently in use on your screen are…

TL;DR: Thinking in components — No longer do you have to maintain bunch of style-sheets. CSS-in-JS abstracts the CSS model to the component level, rather than the document level (modularity). You…
Continue reading “All You Need To Know About CSS-in-JS – Hacker Noon”

Learn JavaScript Promises by Building a Promise from Scratch

How to Easily Build Forms in @reactjs Native:  #JavaScript #Tech

  • But don’t let the fancy name or the fact that there is asynchronous code intimidate you — a Promise is just a plain old JavaScript object with special methods that allow you to execute code synchronously (it will do things in order even though there is a delay).
  • typeof new Promise((resolve, reject) = {}) === ‘object’ // trueLet me reiterate (because this is something that was difficult for me to grasp when I first learned promises), a Promise is just an object.
  • Behind the scenes, the fetch function is doing something like this.const fetch = function(url) { return new Promise((resolve, reject) = { request((error, apiResponse) = { if (error) { reject(error) } resolve(apiResponse) }) })}The fetch() function makes an http request to the server, but the client doesn’t know when the server…
  • This allows you to chain multiple then()’s since you’re returning the object itself.NOTE: In the native Promise, these then() and catch() functions actually return a new Promise themselves, but for this simple scenario, I’ve only returned this.
  • then() chain.When your asynchronous function calls resolve(apiResponse), the promise object then begins executing onResolve(apiResponse).

The block of code in the .then() waits until it receives the response from the server before it executes anything. This is called a Promise. But don’t let the fancy name or the fact that there is…
Continue reading “Learn JavaScript Promises by Building a Promise from Scratch”

Organizing Tests in Jest – Jeff Lombard – Medium

Organizing Tests in Jest  #jest #javascript #react #softwaretesting #reactjs

  • This includes organization.I’ve seen two popular ways suggested for organizing tests in Jest:Putting all of your test code into a neatly organized /tests directory.Putting your test code next to the files they are testing.Both of these suggestions are valid, but to have the elegance of a master craftsman, we should consider the level of the test that is being written.Testing LevelsThere are many testing levels, but for simplicity we’re just going to talk about two here.
  • “Unit testing refers to tests that verify the functionality of a specific section of code, usually at the function level.
  • |- /main| |- index.js| |- index.test.jsIntegration tests run against many lines of code in many files.
  • So include the type of test right in the name of the and ideal set up would look something like this:|- /main| |- index.js| |- index.unit.test.js|- /supporting| |- fetch.js|- /tests| |- /int| | |- way you can easily find your tests.
  • For unit testing run jest unit and for integration testing run jest int.As with anything, there is no single way of doing this.

If you haven’t already tried out Jest, you should. Even if you’re not using React. It’s dead simple and loaded with some cool features like snapshot testing. Jest does a great job of keeping reports…
Continue reading “Organizing Tests in Jest – Jeff Lombard – Medium”

Why Angular2 is Easier Than AngularJS

Why Angular2 is Easier Than AngularJS #ReactJS

  • The event binding works for any DOM event, without any code required.
  • Simplifies a great deal of things to make it easier to develop in AngularJS
  • HTML that conveys what is doing – Event & Data binding
  • In the write-up, we will go over some of the major reasons why Angular 2 is actually simpler to get started than AngularJS
  • It can also be a better place to start for developers new to AngularJS, where rather than spending time learning a complex beast (and what a beautiful beast it is!

Read the full article, click here.

@react_planet: “Why Angular2 is Easier Than AngularJS #ReactJS

You must know that Angular2 is coming (or is already here, depending on who you speak to!). That said, a lot of people have been up in arms at the drastic changes that Angular2 is proposing over AngularJS

Why Angular2 is Easier Than AngularJS

Apollo Server 0.2: GraphQL with Express, Connect, HAPI or Koa — Building Apollo — Medium

Apollo Server 0.2: GraphQL with Express, Connect, HAPI or Koa  #ReactJS

  • We removed support for defining GraphQL schemas in schema language and moved it to an entirely separate npm module – graphql-tools .
  • We also wanted to make the project more maintainable by using TypeScript.
  • Express-graphql could adopt those features of Apollo Server which have proven themselves in practice.
  • Query Batching is a feature we recently introduced in Apollo Client, but it involved merging multiple queries into a single one, which made the queries sent to the server hard to read.
  • Apollo Server is a GraphQL server for JavaScript, built by an open-source community of GraphQL enthusiasts.

Read the full article, click here.

@ReactiveConf: “Apollo Server 0.2: GraphQL with Express, Connect, HAPI or Koa #ReactJS”

A simple and modular GraphQL server for Node.js

Apollo Server 0.2: GraphQL with Express, Connect, HAPI or Koa — Building Apollo — Medium