With styled-components into the future – 💅 styled-components – Medium

With styled-components into the future  #styledcomponents #react #cssinjs #css #reactjs

  • Those remain the same and intact.While this sounds like no more can be achieved from a library that was mostly about best practices and common patterns in CSS, we are still in a position to drive change in the community.And this is because of the ecosystem that people have created…
  • Even more so with our new docs that we’ve published a few months ago.But the real question is, what makes it the library you know and love?There’s a lot of great content and talks from both Max and Glen, so if you’re new to what the ideas of the library are,…
  • [1]Then we have to transform the CSS to be able to inject it [2], and finally inject your CSS into the stylesheet, at the position that we’ve marked earlier.In v2 and onwards we’ve focused a lot on optimising all of the different steps involved here for performance, but one step…
  • The idea that becomes increasingly important here is, that we can’t build a library that works for some special use cases, but what we can build is a CSS infrastructure that allows you to change the CSS yourself.Let’s see how we could approach this.The interesting thing is that with v1…
  • We can run our transformations during Babel’s transpilation, or during build-time in general.We can build a CSS-in-JS pipeline!This would result in nothing being shipped to the runtime, and as long as we can provide an “opt-in” system, you would still be able to decide whether you’d like to ship the…

styled-components has changed a lot in its past. And we are not even done yet!
Continue reading “With styled-components into the future – 💅 styled-components – Medium”

Writing Server-rendered React Apps with Next.js — SitePoint

Writing Server-rendered #ReactJS Apps with Next.js:  by @sitepointdotcom #JavaScript

  • This gets you all the dependencies you need for starting: – $ npm install next react react-dom –save – – Create a directory for your app, and inside that create a directory called pages.
  • js inside your project with these contents: – export default () = ( – divHello, Next!
  • So, you just have a style component inside your React Component render function: – export default () = ( – div – Hello world – pThese colors are scoped!
  • So, you can write code like this that dynamically loads a React component after initial load: – import dynamic from ‘next/dynamic’ – – const = dynamic( – { – loading: () = pThe component is loading…/p – } – ) – – export default () = – div – Header…
  • Next renders pages on the server, and they can be loaded just like good old rendered web pages when JavaScript is disabled.

Jatin Shridhar pushes through JS framework fatigue to introduce Next.js, a simple yet customizable solution to building production-ready SPAs.
Continue reading “Writing Server-rendered React Apps with Next.js — SitePoint”

Leverage New Features of React 16

  • React 16 comes with some powerful new features, in this course we’ll be exploring each of them.
  • Each lesson is going to go over every individual new feature, one at a time.
  • From the new error boundaries that will save us many a headache to handling whether to update our state within our – – We won’t just be learning the technical capabilities of the new features however, we’ll also be going into best practices.
  • Once you watch this course you’ll be more than ready to leverage everything React 16 has to offer!

React 16 comes with some powerful new features, in this course we’ll be exploring each of them. Each lesson is going to go over every individual new feature, one at a time.
From the new error boundaries that will save us many a headache to handling whether to update our state within our setState
We won’t just be learning the technical capabilities of the new features however, we’ll also be going into best practices.
Once you watch this course you’ll be more than ready to leverage everything React 16 has to offer!

Continue reading “Leverage New Features of React 16”

Writing Server-rendered React Apps with Next.js — SitePoint

  • This gets you all the dependencies you need for starting: – $ npm install next react react-dom –save – – Create a directory for your app, and inside that create a directory called pages.
  • js inside your project with these contents: – export default () = ( – divHello, Next!
  • So, you just have a style component inside your React Component render function: – export default () = ( – div – Hello world – pThese colors are scoped!
  • So, you can write code like this that dynamically loads a React component after initial load: – import dynamic from ‘next/dynamic’ – – const = dynamic( – { – loading: () = pThe component is loading…/p – } – ) – – export default () = – div – Header…
  • Next renders pages on the server, and they can be loaded just like good old rendered web pages when JavaScript is disabled.

Jatin Shridhar pushes through JS framework fatigue to introduce Next.js, a simple yet customizable solution to building production-ready SPAs.
Continue reading “Writing Server-rendered React Apps with Next.js — SitePoint”

Easily Styling React Apps In JavaScript

Easily Styling React Apps In JavaScript

☞ 

#reactjs #javascript

  • While many developers still use CSS to style their React apps, writing styles in JavaScript has become an increasingly popular practice as it gives all of the conveniences of CSS preprocessors without the need to learn a new language.
  • Most CSS-in-JS libraries involve creating a JavaScript object of styles.
  • As an example, this is what a style object looks like using my preferred library, Aphrodite.
  • For example, when styling placeholder text, I use a function that returns an object of styles:

    One of biggest advantages of writing styles in JavaScript is that classNames are scoped to each component by default.

  • There are lots of helpful libraries for creating JavaScript styles.

Writing styles React Apps in JavaScript has become an increasingly popular practice as it gives all of the conveniences of CSS preprocessors
Continue reading “Easily Styling React Apps In JavaScript”

When to use Component or PureComponent – codeburst

When to use Component or PureComponent:  #ReactJS

  • Thus, the component will re-render by default whenever shouldComponentUpdate is called.Shallow Comparison 101When comparing previous props and state to next, a shallow comparison will check that primitives have the same value (eg, 1 equals 1 or that true equals true) and that the references are the same between more complex javascript values like objects and arrays.Never MUTATEYou’ve probably been hearing not to mutate objects and arrays in props and state.
  • Although the values have changed upstream, the child would be comparing the reference to the previous props and not detect a difference.Instead, return new objects when you make a change by either leveraging es6 for object and array spreading or using a library to enforce immutability.Are there a performance issues?Comparing primitives and object references is an incredibly cheap operation.
  • If you have a list of child objects and one of the children updates, doing a check on their props and state is lightning fast compared to the cost of re-rendering each one.Other ways you could slip upDon’t bind values in functions in renderSay you have a list of items, each passing a unique parameter to parent method.
  • CommentItem likeComment={this.likeComment} userID={user.id} /Then in the child component create a class method that will reference its props:class CommentItem extends PureComponent { … handleLike() { } …}Don’t derive data in the render methodConsider a list of articles from which your profile component will display the user’s 10 most liked pieces.render() { const { posts } = this.props const topTen = posts.sort((a, b) = b.likes – a.likes).
  • slice(0, 9) return //…}topTen will have a brand new reference each time the component re-renders, even if posts hasn’t changed and the derived data is the same.

I switched to using PureComponent awhile back on the premise of it being a more performant version of Component. This turned out to be true, but the performance gains come with a few strings attached…
Continue reading “When to use Component or PureComponent – codeburst”

My hyper-talented friend is looking for front-end dev work (React/JS) from October onwards. His site: . Pls share!

  • I quickly came to depend on Ben’s knowledge and expertise on all aspects of the development of our Backbone.js app.
  • I don’t think the workshop would have been such a success without Ben.”
  • “Ben was able to apply his front-end development and architecture experience from day one, helping us come up with and validate key architecture choices and avoid costly mistakes as we scale Kayako to be used by 10,000s organisations worldwide to support millions of end users.
  • We found Ben’s advice to be realistic and pragmatic, factoring in resource constraints, business needs of the day and balancing those with future scalability benefits.
  • “Ben’s Javascript for Beginners workshop was extremely useful.

I can work with you to plan, architect and review how you can achieve seamless development, so I can impart my knowledge and point you in the right direction. I’m well versed in where and how bottlenecks can appear, but also how to solve and avoid them.
Continue reading “My hyper-talented friend is looking for front-end dev work (React/JS) from October onwards. His site: .

Pls share!”