ut

Preparing for the Future with React Prereleases

To share upcoming changes with our partners in the React ecosystem, we’re establishing official prerelease channels. We hope this process will help us make changes to React with confidence, and give developers the opportunity to try out experimental features.

This post will be most relevant to developers who work on frameworks, libraries, or developer tooling. Developers who use React primarily to build user-facing applications should not need to worry about our prerelease channels.

React relies on a thriving open source community to file bug reports, open pull requests, and submit RFCs. To encourage feedback, we sometimes share special builds of React that include unreleased features.

Because the source of truth for React is our public GitHub repository, it’s always been possible to build a copy of React that includes the latest changes. However it’s much easier for developers to install React from npm, so we occasionally publish prerelease builds to the npm registry. A recent example is the 16.7 alpha, which included an early version of the Hooks API.

We would like to make it even easier for developers to test prerelease builds of React, so we’re formalizing our process with three separate release channels.

Release Channels

The information in this post is also available on our Release Channels page. We will update that document whenever there are changes to our release process.

Each of React’s release channels is designed for a distinct use case:

  • Latest is for stable, semver React releases. It’s what you get when you install React from npm. This is the channel you’re already using today. Use this for all user-facing React applications.
  • Next tracks the master branch of the React source code repository. Think of these as release candidates for the next minor semver release. Use this for integration testing between React and third party projects.
  • Experimental includes experimental APIs and features that aren’t available in the stable releases. These also track the master branch, but with additional feature flags turned on. Use this to try out upcoming features before they are released.

All releases are published to npm, but only Latest uses semantic versioning. Prereleases (those in the Next and Experimental channels) have versions generated from a hash of their contents, e.g. 0.0.0-1022ee0ec for Next and 0.0.0-experimental-1022ee0ec for Experimental.

The only officially supported release channel for user-facing applications is Latest. Next and Experimental releases are provided for testing purposes only, and we provide no guarantees that behavior won’t change between releases. They do not follow the semver protocol that we use for releases from Latest.

By publishing prereleases to the same registry that we use for stable releases, we are able to take advantage of the many tools that support the npm workflow, like unpkg and CodeSandbox.

Latest Channel

Latest is the channel used for stable React releases. It corresponds to the latest tag on npm. It is the recommended channel for all React apps that are shipped to real users.

If you’re not sure which channel you should use, it’s Latest. If you’re a React developer, this is what you’re already using.

You can expect updates to Latest to be extremely stable. Versions follow the semantic versioning scheme. Learn more about our commitment to stability and incremental migration in our versioning policy.

Next Channel

The Next channel is a prerelease channel that tracks the master branch of the React repository. We use prereleases in the Next channel as release candidates for the Latest channel. You can think of Next as a superset of Latest that is updated more frequently.

The degree of change between the most recent Next release and the most recent Latest release is approximately the same as you would find between two minor semver releases. However, the Next channel does not conform to semantic versioning. You should expect occasional breaking changes between successive releases in the Next channel.

Do not use prereleases in user-facing applications.

Releases in Next are published with the next tag on npm. Versions are generated from a hash of the build’s contents, e.g. 0.0.0-1022ee0ec.

Using the Next Channel for Integration Testing

The Next channel is designed to support integration testing between React and other projects.

All changes to React go through extensive internal testing before they are released to the public. However, there are myriad environments and configurations used throughout the React ecosystem, and it’s not possible for us to test against every single one.

If you’re the author of a third party React framework, library, developer tool, or similar infrastructure-type project, you can help us keep React stable for your users and the entire React community by periodically running your test suite against the most recent changes. If you’re interested, follow these steps:

  • Set up a cron job using your preferred continuous integration platform. Cron jobs are supported by both CircleCI and Travis CI.
  • In the cron job, update your React packages to the most recent React release in the Next channel, using next tag on npm. Using the npm cli:

    npm update react@next react-dom@next

    Or yarn:

    yarn upgrade react@next react-dom@next
  • Run your test suite against the updated packages.
  • If everything passes, great! You can expect that your project will work with the next minor React release.
  • If something breaks unexpectedly, please let us know by filing an issue.

A project that uses this workflow is Next.js. (No pun intended! Seriously!) You can refer to their CircleCI configuration as an example.

Experimental Channel

Like Next, the Experimental channel is a prerelease channel that tracks the master branch of the React repository. Unlike Next, Experimental releases include additional features and APIs that are not ready for wider release.

Usually, an update to Next is accompanied by a corresponding update to Experimental. They are based on the same source revision, but are built using a different set of feature flags.

Experimental releases may be significantly different than releases to Next and Latest. Do not use Experimental releases in user-facing applications. You should expect frequent breaking changes between releases in the Experimental channel.

Releases in Experimental are published with the experimental tag on npm. Versions are generated from a hash of the build’s contents, e.g. 0.0.0-experimental-1022ee0ec.

What Goes Into an Experimental Release?

Experimental features are ones that are not ready to be released to the wider public, and may change drastically before they are finalized. Some experiments may never be finalized — the reason we have experiments is to test the viability of proposed changes.

For example, if the Experimental channel had existed when we announced Hooks, we would have released Hooks to the Experimental channel weeks before they were available in Latest.

You may find it valuable to run integration tests against Experimental. This is up to you. However, be advised that Experimental is even less stable than Next. We do not guarantee any stability between Experimental releases.

How Can I Learn More About Experimental Features?

Experimental features may or may not be documented. Usually, experiments aren’t documented until they are close to shipping in Next or Stable.

If a feature is not documented, they may be accompanied by an RFC.

We will post to the React blog when we’re ready to announce new experiments, but that doesn’t mean we will publicize every experiment.

You can always refer to our public GitHub repository’s history for a comprehensive list of changes.




ut

Medium-hard SQL questions to think about

#354 — May 6, 2020

Read on the Web

Postgres Weekly

pgModeler: A Postgres Database Modeler — An easy way to create and edit database models in a visual way. It’s packaged up as a paid product but is also open source so you can build your own.

Raphael Araújo e Silva

The Best Medium-Hard Data Analyst SQL Interview Questions — This article begins with a quote: “The first 70% of SQL is pretty straightforward but the remaining 30% can be pretty tricky.” True! This article focuses on the tricky ‘medium-hard’ area that few tutorials venture into.

Zachary Thomas

Monitor Custom Postgres Metrics in Real-Time with Datadog — Monitor and visualize Postgres performance in context end-to-end alongside the rest of your stack. Create custom, drag-and-drop dashboards to quickly view analytics on any Postgres metric. Try Datadog free.

Datadog sponsor

My Favorite PostgreSQL Extensions: Part Two — The second part of a series we linked to last week. This time, Nawaz takes a look at pgAudit, pg_repack, and HypoPG.

Nawaz Ahmed

Backup Manifests and pg_verifybackup in Postgres 13 — Postgres 13 will introduce two features to enhance the automated validation of physical backups: backup manifests and a new tool called pg_verifybackup.

Gabriele Bartolini

arm64 Packages Now on apt.postgresql.org — If you’re running ARM64 hardware and Debian or Ubuntu, you can now install Postgres via apt.

Christoph Berg

Speeding Up count(*): Why Not Use max(id) - min(id)? — A warning tale in case you decide to take this shortcut. While you might be able to estimate or fudge a number that’s close, you can’t guarantee sequences will give you an exact, correct answer here.

Hans-Jürgen Schönig

Using Postgres for JSON Storage — With JSON and JSONB types and associated advanced ways to query such columns, using Postgres as a store for JSON data is pretty simple. This is the briefest of overviews but leads into an interactive online tutorial.

Steve Pousty

How to Migrate From Inheritance-Based Partitioning to Declarative Partitioning — Partitioning was introduced in Postgres 10 and Postgres 11 improved the declarative partitioning support. This article demonstrates a move from inheritance based partitioning to declarative partitioning using the native features found in Postgres 11+.

Caterina Magini

Free eBook: How to Get a 3x Performance Improvement on Your Postgres Database — Learn our best practices for optimizing Postgres query performance for customers like Atlassian and how to reduce data loaded from disk by 500x.

pganalyze sponsor

How to Backup Multiple Tablespaces with pg_basebackup

Ahsan Hadi

▶  Security and Compliance with Postgres — A recorded webinar that 2ndQuadrant ran recently.

Boriss Mejías

Oracle to PostgreSQL: ANSI Outer Join Syntax in Postgres — The latest in a series of blog posts about migrating to Postgres from Oracle which looks at what Postgres offers in place of Oracle’s join operators.

Kirk Roybal

An Interview with 2ndQuadrant's Jimmy Angelakos — The latest ‘PostgreSQL Person of the Week’ to face questions about his experiences with Postgres.

Andreas Scherbaum

dadbod.vim: A Modern Database Interface for Vim — A Vim plugin for interacting with numerous databases, including Postgres.

Tim Pope

???? Upcoming Online Events

  • Postgres Pulse - weekly at 11am ET each Monday. Weekly Zoom-based sessions with folks like Bruce Momjian, Vibhor Kumar, and other people at EnterpriseDB.
  • ???? Postgres Vision 2020 on June 23-24. A full attempt at an online Postgres conference across multiple days with multiple tracks.

???? – requires e-mail address or registration
???? – costs money to participate




ut

An interview with Ruby ETL expert Thibaut Barrère

#499 — April 30, 2020

Read on the Web

???? Occasionally we run interviews in Ruby Weekly and we're back with another one.. with long time Rubyist and Kiba maintainer, Thibaut Barrère. Be sure to check out the bottom of this issue to read it, especially if you ever run ETL jobs with Ruby! ????

Ruby Weekly

▶  Let's Build a Twitter Clone in 10 Minutes with Rails, CableReady, and StimulusReflex — You know that cloning Twitter in 10 minutes is impossible, but what about the core mechanism of the idea? After a slow first minute, this video does a pretty good job of showing off some techniques you might not have used before.

Nate Hopkins

discuss.rubyonrails: The Rails Project Discussion Forum — Basically a Web version of the Rails mailing lists and a worthwhile place to head if you want to suggest features, ask questions, etc.

Ruby on Rails Discussions

Easy Rails Deployments — Deploy your Ruby, Rails, Sinatra, and Rack application to any cloud or server. Cloud 66 offers a scalable Heroku alternative that doesn't lock you in. Try it free and get extra $66 free credits with the code: 'Ruby-Weekly'.

Cloud 66 sponsor

sequel-activerecord-adapter: Allows Sequel to Reuse an ActiveRecord Connection — If you want to use more Sequel or migrate in that direction, this makes it easy.

Janko Marohnić

Ruby Adds Experimental Support for 'End-Less' Method Definitions — We’ve touched on this in a previous issue, but if you fancy a proper blog post with examples, this is more accessible than digging through feature tracker discussions. I’m not a fan of this syntax myself yet, but Prateek does a good job of selling it.

Prateek Choudhary

CableReady: Trigger Client-Side DOM Changes from Server-Side Ruby — If you skipped the video above because it’s a video (and I know many of you do ????) CableReady is still worth checking out. It aims to “complete the ActionCable story” by providing a way to directly interact with clients over ActionCable WebSockets. The docs will help you get the idea.

Hopsoft

???? Jobs

Find a Job Through Vettery — Vettery specializes in tech roles and is completely free for job seekers. Create a profile to get started.

Vettery

Security Engineer (Remote) — Are you an engineer with experience in Rails and/or Go? Join our team and help secure our apps and cloud infrastructure.

Shogun

ℹ️ Interested in running a job listing in Ruby Weekly? There's more info here.

???? Articles & Tutorials

A Practical Use for PStorePStore is one of the older parts of Ruby’s stdlib and lets you persist (and restore) a Ruby hash to disk. I haven’t seen it in Ruby code for years but Arkency have found a neat, modern use case.

Paweł Pacana

▶  Drag and Drop Sortable Lists with Rails and Stimulus JS — How to wire up drag and drop lists with a Rails app using Sortable, Stimulus and acts_as_list.

Go Rails

Setting Up Multi-Factor Authentication for RubyGems.org — If you’re a registered user of the official Ruby Gems repository, you should have had an email this week about securing your account using 2FA. This is just my own reminder that this is a good idea especially if you publicly publish widely used gems! :-)

Rubygems.org

Let’s Explore Big-O Notation With Ruby ???? — Learn to use Big-O to look at an algorithm and easily discern its efficiency, without having to run a profiling tool.

Honeybadger sponsor

▶  Discussing Docker and Kubernetes with Kelsey Hightower — A worthwhile show to listen to if Kubernetes and Docker intimidate you but you want to know a little more. Kelsey is good at breaking these things down into understandable pieces.

Rails with Jason Podcast podcast

Rails System Tests in Docker — We’re seeing an uptick in articles about system tests in Rails. Here’s how to integrate them into your development Docker setup.

Hint.io

The Difference Between System Specs and Feature Specs — If you’ve felt the difference between RSpec’s “feature specs” and “system specs” is quite subtle, this explanation will help.

Jason Swett

Why Rubyists Should Consider Learning Go — If you want compilation and a type system, Crystal is probably a better fit for Rubyists, but Go is undoubtedly a neat language and ecosystem (and if you do end up in the Go world, check out our Go weekly! ????)

Ayooluwa Isaiah

Building a Ruby CLI with Thor

Daniel Gómez

???? Code and Tools

git curate: Peruse and Delete git Branches Ergonomically — Got a repo cluttered with branches here and there? git curate aims to cure the pains of getting those branches back under control.

Matt Harvey

MessageBus: A Reliable and Robust Messaging Bus for Ruby and Rack

Sam Saffron

Are You Spending Too Much on Heroku?

Rails Autoscale sponsor

bootstrap_form: A Rails Form Builder for Bootstrap v4-Style Forms

Bootstrap Ruby

ActiveModelAttributes: The Active Record Attributes API, but for Active Model — Brings some of the goodies of the Rails 5 Active Record attributes API to ActiveModel too. 1.6.0 just dropped.

Karol Galanciak

???? A Q&A with…
Thibaut Barrère
Creator of Kiba ETL

Thibaut Barrère is a long-time Rubyist and data engineer who built and maintains the popular Extract, Transform, and Load (ETL) framework Kiba. We asked him some questions about his work:

What inspired you to create Kiba?

A lot of my work since ~2005 has been focused on data integration (making systems speak together), data aggregation etc. I sometimes used GUI-based tools like Microsoft SSIS which, while powerful, are quite far from the coding experience.

I was already using Ruby at that time, and was happy to discover activewarehouse-etl (maintained by Anthony Eden, who runs DNSimple now) providing a Ruby DSL to declare data pipelines. I used it for a while with very good success to implement data extractions and business intelligence ETL, and ultimately took over the maintenance.

In the long run, though (as I explained in a recent Paris.rb talk), the balance between the the cost of OSS maintenance and the usability for my billable and non-billable use-cases proved to be not good enough, which made me decide to stop the maintenance, sadly.

I still wanted to use Ruby to write data pipelines, but I needed to cover more use-cases and reduce the OSS maintenance burden at the same time. This ultimately led me to write and share (in 2015) Kiba ETL, a focused DSL for declarative processing, matching those criterias.

Do you find yourself adding more features while in quarantine?

Before the quarantine, I directed my Kiba bandwith and focus on finalizing Kiba v3 and rewriting the documentation from scratch, to properly encourage best practices I’ve been discovering. I also created experimental branches for Ruby 2.7/2.8 keywords.

During the quarantine, I've reduced client work and OSS work too, to focus on shipping Kiba Pro v2 (which I’ll announce shortly officially). I’ve extracted and generalized (from real-life projects) very useful components, such as a “batch SQL lookup” (useful when replacing relationships keys during data migrations and datawarehouses sync code, in batch rather than row by row), a “file lock” to ensure a single job runs at once, and a “parallel transform” to achieve easy concurrency for things like HTTP queries.

What's the wildest ETL that you've encountered?

Getting the data out of a system which is actively not acting in that direction is always a bit wild.. One can see all types of fancy stuff on the field. For instance, it is not uncommon to have an ETL process start a headless browser, jump through pages, just to get to the CSV/PDF/Excel file that you will then use as your data source!

You can also end up having to figure out ways to read or write very old file formats at times. Recently I wrote a Kiba component to generate a COBOL delimited file, for instance. In large companies, a very widely used I/O is good old SFTP, far away from modern APIs and formats.

Can you tell us how to say your last name? ????

I had to deploy a page to my blog to answer that question properly ????. You’ll find out how to say my name here.

Merci Thibaut!

You can read some of Thibaut's posts on his blog and find out more about Kiba ETL here.




ut

A transpiler for futuristic Ruby, and the RailsConf 2020 videos

#500 — May 7, 2020

Read on the Web

???? Welcome to issue 500! A bit of an arbitrary milestone but thanks to you all :-)

Ruby Weekly

Ruby Next: Make All Rubies Quack Alike — Ruby Next is a Ruby-to-Ruby transpiler that allows you to use the latest features of Ruby in previous versions without monkey patching or refinements. Could this be how experimental features are released going forward?

Vladimir Dementyev

Ruby 3 'Guilds' Proposal Now Called Ractor — This documentation is in Japanese (though the source code examples are easy to follow) but the news is that the new, proposed concurrency mechanism for Ruby 3 called Guilds (explained here) has been renamed to Ractor (as in ‘Ruby actors’, Ruby’s take on the actor model).

Koichi Sasada

Don’t Do Auth From Scratch. Focus On Your App — Spend less time on authentication and authorization and more time developing your awesome app. Auth built for <devs>. Download our community edition for free.

FusionAuth sponsor

Take the 2020 Ruby on Rails Survey — This is the sixth outing for Planet Argon’s survey which began in 2009. We try and support it each time as the results always make for interesting reading (see 2018’s results). Participate and become data ????

Planet Argon Team

???? RailsConf 2020 Videos

If you recall, RailsConf 2020 was cancelled in its in-person form to be replaced by a 'couch edition'. This has been taking place and the videos have been released! Here are some of the highlights:

If you want the full collection, here's the YouTube playlist.

Alt::BrightonRuby: A Slightly Odd, Quasi-Conference for Strange Times — Alt::BrightonRuby is not happening in-person this year. Instead, you can buy the recorded talks, get a _why book, and get some podcasts with the speakers.

Alt::BrightonRuby

???? Jobs

Find a Job Through Vettery — Vettery specializes in tech roles and is completely free for job seekers. Create a profile to get started.

Vettery

Security Engineer (Remote) — Are you an engineer with experience in Rails and/or Go? Join our team and help secure our apps and cloud infrastructure.

Shogun

ℹ️ Interested in running a job listing in Ruby Weekly? There's more info here.

???? Articles & Tutorials

▶  How To Begin Contributing to a Gem — If you’ve been using a library for a while and you want to contribute back, how do you get started? A 12 minute introduction here.

Drifting Ruby

How to Set Up Factory Bot on a Fresh Rails Project — Factory Bot is a library for setting up Ruby objects as test data – an alternative to fixtures, essentially.

Jason Swett

Using Postgres's DISTINCT ON to Avoid an N+1 Query“Recently I fixed a tricky N+1 query and thought I should write it up..”

John Nunemaker

Need to Upgrade Rails? Don’t Know How Long It Will Take? — Get an action plan for your Rails upgrade and an in-depth report about your technical debt and outdated dependencies ????.

FastRuby.io | Rails Upgrade Services sponsor

5 Uses for 'Splats' — 5 different ways to leverage Ruby’s splat (*) operator.

Jason Dinsmore

Running Multiple Instances of Webpacker — If you’re working on multiple Rails apps at once, changing where Rails gets served up is easy by configuring the port, but what about Webpacker? That requires another tweak.

Scott Watermasysk

Performing Asynchronous HTTP requests in Rails — How to update parts an app’s pages with asynchronous HTTP requests. A step-by-step how-to with JavaScript’s fetch() function, and Rails native server-side partial rendering.

Remi Mercier

How to Use AWS SimpleDB from Ruby — If you haven’t heard of AWS SimpleDB, you wouldn’t be alone as it’s not very popular, but it’s a pretty simple and cheap way to store simple documents in the cloud.

Peter Cooper

What's The Difference Between Monitoring Webhooks and Background Jobs

AppSignal sponsor

Ways to Reduce Your Heroku App's Slug Size — You might be surprised Heroku didn’t already do some of this for you.

Rohit Kumar

A Chat with Thibaut Barrère — If you missed our interview with Thibaut Barrere (Rubyist, and creator of the Kiba ETL framework) in last week’s issue, you can catch up here.

Glenn Goodrich

???? Code and Tools

Rodauth 2.0: Ruby's 'Most Advanced' Authentication Framework — A authentication framework that can work in any Rack-based webapp. Built using Roda and Sequel, Rodauth can be used with other frameworks and database libraries if you wish. Why’s it so advanced? More info on that here.

Jeremy Evans

RubyGems 3.1.3 Released — Lots of little bug fixes and tweaks.

RubyGems Blog

Business: Business Day Calculations for Ruby — Define your working days and holidays and then you can do ‘business day arithmetic’ (for example, what’s in 5 working days after now taking holidays and weekends into account?)

GoCardless

Lockbox: Modern Encryption for Rails

Andrew Kane

split: The Rack Based A/B 'Split' Testing Framework — A mature framework with robust configuration and multiple options for determining the winning option.

Split

P.S. In last week's issue, one of the links to our sponsors was incorrect and some readers emailed us to say they really wanted to read the promised article, Let’s Explore Big-O Notation with Ruby, so here it is. Apologies for any inconvenience.




ut

Life and struggle after YouTube fame

Dax was one of YouTube's first stars, but 13 years later, few people remember his name. Can a vlogging legend seize glory again?




ut

Coronavirus: The grandad who became a TikTok star without realising it

Joe Allington was persuaded to dance on TikTok for the first time in January. Now he's got 1.5 million followers.




ut

Why being gay in Russia is about "love and passion"

The secret moment between two gay Russian lovers that defied haters.




ut

Coronavirus: DIY hair shaving and beauty treatments

As hair dye and clippers become the next thing on the stockpile list - we look at how people are managing their hair and beauty.




ut

Coronavirus: Brazil's outbreak 'threatens Paraguay's success'

Paraguay's president says he has reinforced the border with the worst-hit country in South America.




ut

React Router & Webpack in Production

I’ve been working on a pretty large react-router codebase at work. Currently it has around 50~ code splits, which as you can imagine, is a lot of routes. This is going to be a post on the things I’ve learned throughout building out my development / production config and how we are using webpack in production.

###Initial Setup

Before I really dive into how my webpack config is setup and the problems I’ve found, I’ll quickly go over how this app is setup. Currently, there’s one entry point and it looks like this:

import React from 'react'
import { render } from 'react-dom'
import { match, Router, browserHistory } from 'react-router'
import AsyncProps from 'async-props'
import routes from '../routes/index'
/* globals document, window */

const { pathname, search, hash } = window.location
const location = `${pathname}${search}${hash}`

match({ routes, location }, () => {
  render(
    <Router
      render={props => <AsyncProps {...props}/>}
      routes={routes}
      history={browserHistory}
    />,
    document.getElementById('app')
  )
})

It looks like a standard react-router setup, except a couple things are different. For one, there’s way too many routes to have them all in this file, so we are importing the main route object into this file. Second, we are using match on the client side. Without matching first, the client side would try to render before the splits were downloaded causing an error. You can read a little more about match on the client here.

Next, we are using Ryan Florence’s awesome async-props library for loading data into components. It allows me to load data from an api before the server renders components. It will pass the data down to the client for the client-side render, and then data will load as you navigate to new pages automatically.

###Routes

Our main routes file looks like this:


export default {
  component: 'div',
  path: '/',
  indexRoute: require('./index'),
  childRoutes: [
    require('./login'),
    require('./account'),
    ...
  ]
}

There’s a lot more require’s in our app of course. And these are nested pretty deep. The files referenced in the root file have more child routes, and those use require.ensure which you can read about in the webpack docs on code splitting. It tells webpack to make a new bundle, and then load that bundle when require.ensure is called on the client. Here’s an example:

if(typeof require.ensure !== "function") require.ensure = function(d, c) { c(require) }

module.exports = {
  path: 'account',
  getComponent(location, cb) {
    require.ensure([], (require) => {
      cb(null, require('../../views/master/index.jsx'))
    })
  },
  childRoutes: [
    require('./settings'),
  ]
}

There’s a few things going on here. First, we have a function at the top that will polyfill require.ensure. Why? Well, on this project we are server rendering our whole site as well, which I would rather not do, but due to the type of site we are building: we have to. The next thing is the relative require path. I’m using this awesome babel resolver plugin along with webpack’s resolve paths so that I can import files like this:

import Header from '../../master/header'
//becomes
import Header from 'master/header'

Why do I have to use a babel plugin AND webpack’s resolve feature? Once again, doing a server rendered app, the code is ran on the server and also through webpack. In this particular app, I haven’t had time to experiment with webpacking the server. Anyways, if I didn’t use the babel plugin, errors would be thrown on the server, but webpack would work fine. This is one of the common things I have ran into while building this app.

Realizing some things need to be done slightly different on the server or client. You may still be wondering why I am referencing the component as a relative path in the above route example, and that’s because the babel plugin I’m using only works with import and not require. My route objects are the one place that I have these “nasty” looking paths.

##Webpack

I was prompted to make this article after tweeting this out:

A couple people wanted a better explanation as to what’s happening here. When I was first building my production webpack config, even after using all of these plugins:

new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.js'),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
  compress: { warnings: false },
  comments: false,
  sourceMap: false,
  mangle: true,
  minimize: true
}),

My bundle looked like this:

That’s pretty huge if you think about it. And I’m not talking about the amount of bundles. I’m talking about the file size. After searching everywhere for a solution to get the bundle size down further, I found webpack’s AggressiveMergingPlugin. This thing is a life saver. As you may have seen from the tweet, the output turns into this:

Just having the main, vendor, and one other bundle brings the whole site under 1MB. I’m using the plugin to only merge files if the size reduction is more than 50%, which is the default.

People talk about code splitting in webpack and think it’s really amazing to load the JS for the page you’re on and nothing more. It sounds great. The problem is that the file size is immensely bigger. If someone more familiar with webpack has a better idea as to why this is, I’d like a better explanation. It isn’t feasable to keep the splits instead of merging them. This site is pretty large, with a lot of routes as you can tell from the screenshots. Codesplitting without merging would cause way more waiting on the client side every time you navigate to a new page. Even if the JS was heavily cached, the first time you hit these pages it will have to load a 300kb bundle for some of them.

##Caching

That takes us to caching. We are about a month away from publicly launching this site, so we haven’t setup the workflow for pushing updates through a cdn, but that will be the end result. For now, in my webpack config, my output object looks like this:

output: {
  path: __dirname + '/public/assets/js/[hash]/',
  filename: '[name].js',
  chunkFilename: '[id].js',
  publicPath: '/assets/js/[hash]/'
},

This is in the production config of course. This way I can cache the files and when I update the code, the hash will change and the browser won’t be caching the old code. I pass in the hash as an env variable at runtime to that the server has the correct path to the assets folder.

##Problems

There were a few big problems I came across while building out a server rendered app with dynamic routes. The first was page titles. How am I supposed to have the right title on the client and on the initial server render? Thankfully, Ryan has yet another solution. react-title-component solves this perfectly.

The next was, how do I hit an api, wait for the response on server render, load new data on route changes, and of course, do this at the component level. As I mentioned before, async-props solves this problem too. It will give you route info so that you can make requests based on things in the url.

The next problem is one that I haven’t fully solved. Webpack is getting really slow. It takes around 20 seconds on a maxed out macbook 15” to build code in production. On the server, it takes more like a minute! If I’m in development mode, it takes around 10 seconds to make the initial build, and sometimes it lags on building the splits on code change. If anyone has insight into this I would love to hear it.

This one goes along with the webpack one, and it is reloading the server. I haven’t tried to webpack the server but I hear doing so works great for this. I don’t think it would fix the problem with webpack being slow though, and in fact it would probably make it even slower.

##Folder structure

I almost forgot to throw this one in here! I’m really happy with the structure of this project. I have a views folder that has all of the same folders and file names as the routes folder. It makes it really easy to find things. These also correspond with the URL to the page. /account/settings will be in views/account/settings.jsx and routes/account/settings.js. The same is true for my tests folder.

##Conclusion

I hope this gave you a good glimpse at how webpack and react router work at a larger scale than you see most blog posts cover. If you have any questions or things that you would like me to talk about that I haven’t already, please leave a comment below and I will update this post! I’m sure that I forgot a few problems and tips writing this. I was thinking this would be a short post but it blew up on me!




ut

Routing in React Native with Jake Murzy

Jake Murzy has been hard at work creating a new navigational library for React Native over the last couple of months. While React JS has the benefit of the highly-regarded React Router, such a comprehensive routing solution doesn’t exist yet in the React Native community. In fact, React Native’s routing landscape has been in constant upheaval for the last year. The library itself has official three ‘navigators’ for handling decision making on which components to show the user, including ‘NavigatorIOS’, ‘Navigator’, and - more recently - ‘NavigatorExperimental’. The open source community likewise has the packages ‘React Native Router Flux’, ‘React Native Router Native’, and ‘React Native Redux Router’, which of which are in various states of completion, or, more commonly, disrepair.

Jake Murzy has been hard at work creating a new navigational library for React Native over the last couple of months. While React JS has the benefit of the highly-regarded React Router, such a comprehensive routing solution doesn’t exist yet in the React Native community. In fact, React Native’s routing landscape has been in constant upheaval for the last year. The library itself has official three ‘navigators’ for handling decision making on which components to show the user, including ‘NavigatorIOS’, ‘Navigator’, and - more recently - ‘NavigatorExperimental’. The open source community likewise has the packages ‘React Native Router Flux’, ‘React Native Router Native’, and ‘React Native Redux Router’, which of which are in various states of completion, or, more commonly, disrepair.

React Router Native appears to focus on matching the API of the immensely popular React Router package, even going as far as introducing the concept of a URL into React Native, which bucks the notion that only web applications need or deserve a URL.


Today Jake is going to share some of his thoughts about his new library.

Q: Hi Jake! The React Native library contains several navigation solutions and the surrounding ecosystem has multiple routing libraries. What made you decide to make your own?

Hey! Thanks for reaching out. I’ve been eagerly watching what’s happening with navigation on React Native for a while. Until very recently, the whole Navigation scene in React Native was a mess. Navigator was being deprecated in favor of NavigationExperimental and NavigationExperimental wasn’t ready for prime time.

My team was just starting a new project so I tried quite a few of the available solutions. Having successfully used React Router on the web, we were looking for a similar solution. Unfortunately, React Router did not support React Native, and other solutions we found were either very unstable, had a hard time keeping up with upstream changes on each release or the quality of code was quite poor.

NavigationExperimental did most of what we wanted but it was a bit too low level so often times we found ourselves writing navigation related code and you can imagine how this gets tedious fast. The low level nature of NavigationExperimental is really by design to allow abstractions to be built up in higher layers. So to finally answer your question, the project came directly out of my frustration trying to make navigation work on React Native as good as React Router did on the web.

Q: What is the strength of your routing system? Is there any type of app that would be a perfect fit with React Router Native? Conversely, is there any type of app that wouldn’t be a good fit with the library?

The use cases for React Router Native is pretty much the same as NavigationExperimental—which is the only supported navigation library by the React Native team. React Router Native is a very thin layer on top of NavigationExperimental that offers React Router’s mental model in a native app. Under the hood, it uses React Router for routing and NavigationExperimental for rendering user components. This is a very powerful combination that makes URLs possible on mobile.

Most apps do not have deep-linking capabilities because implementing it for each screen in your app is a challenging task. Even within apps, users are often forced to take screenshots to share information. And for many, it’s vital that their apps support deep-linking. For example, Yelp goes as far to show a share prompt when users take screenshots of business listings. React Router Native enables developers to implement deep-linking in their apps without putting forth much effort. This can pave the way for a more connected app ecosystem.

That being said, we’re still in the early days of React Native figuring out the right abstractions. Navigation on mobile is a challenging task, and having different flavors is only healthier as the community weighs the pros and cons of each approach rather than second guessing best-practices. So I’m hoping to get the community involved to shape the direction of the project.

Q: Is React Router Native designed to be used with any of the official Navigation components written by the React Native team?

Absolutely. One of the primary goals of the project is that we follow React’s “learn once, write anywhere” principle. So you can use the community maintained components, interpolators and pan responders from React Native, and everything is highly customizable if you need instruct NavigationExperimental to do fancy transition animations, etc.

Q: The React Router team has somewhat famously rewritten their API several times in the last two years, each time introducing several breaking changes. Do you hope to keep your library at parity with React Router, breaking changes and all? Case in point, the V4 release of React Router will introduce an all-new API.

React Router v4 is a complete rewrite. There was a lot of head-scratching on Twitter over the entire new set of breaking changes. Many people thought v4 should at best have been released under a different name. I’m not sure if I agree with that sentiment though, I understand where it is coming from. React Router v4 is a preview release, and in my opinion, it’s really hard to argue against replacing a foreign API with simple React components. I do hope to keep the library at parity with React Router, and to be honest, v4’s new everything-is-a-component approach makes the integration even easier. So over the next few weeks I’ll be working on v4 support.

Q: If you were new to React Native, which routing solution would you use? Why?

This is a hard one to answer. Eric Vicenti has done a great job on NavigationExperimental and most of the issues have been sorted out by the community over the last few months. So if you’re familiar with Redux concepts and comfortable writing your own reducers to manage navigation state, NavigationExperimental is a great choice.

One that I’m surprised you didn’t mention that deserves more attention is ExNavigation—another fairly new addition to the brewery. It also uses NavigationExperimental and is maintained by Adam Miskiewicz, Brent Vatne and other awesome members of the Exponent community. It feels a bit tied to the Exponent platform, but runs perfectly fine on React Native and is open source. So you’ve got that.

Finally, If you’re just getting started with React Native and all you need is to be able to click a button and have it transition to a different scene but you don’t want it to get in your way when you need to reach in and apply complex navigational patterns, I strongly recommend you take React Router Native for a spin.




ut

Yuri Alberto (R) of Brazil celebrates scoring his sides second goal with Rodrigo Guth

Yuri Alberto (R) of Brazil celebrates scoring his sides second goal with Rodrigo Guth during the FIFA U-17 World Cup India 2017 3rd Place match between Brazil and Mali at Vivekananda Yuba Bharati Krirangan on October 28, 2017 in Kolkata, India. (Photo by Tom Dulat - FIFA/FIFA via Getty Images)




ut

Egypt’s Eika puts on a brave face

Egypt's Eika believes that following their gruelling win over Italy, their match against Argentina was one game too far.




ut

Russia outlast Iran to make final

Russia booked their place in the FIFA Futsal World Cup Colombia 2016 final after outlasting Iran 4-3 in Tuesday’s semi-final in Medellin.




ut

Borruto: It’s all about the ball

Argentina's Cristian Borruto explains to FIFA.com how his tough upbringing in Avellaneda helped to turn him into the type of player he his today.




ut

Iran finish third after penalty shootout win

Iran’s remarkable journey at the FIFA Futsal World Cup Colombia 2016 ended on a high note, as they claimed third place after a 4-3 penalty shootout win over Portugal following a 2-2 draw in Cali on Saturday.




ut

FIFA pays tribute to Falcao

Prior to the FIFA Futsal World Cup Colombia 2016 final between Russia and Argentina, FIFA President Gianni Infantino presented Brazilian star Falcao with an Award for Sporting Achievement.




ut

Argentina claim maiden futsal crown

Argentina defeated Russia 5-4 in a dramatic FIFA Futsal World Cup Colombia 2016 final at the Coliseo el Pueblo in Cali to win the country's first-ever Futsal World Cup title.




ut

All change on the futsal scene

If there is one thing that made the FIFA Futsal World Cup Colombia 2016 a turning point in the history of the sport, then it was Argentina's maiden title win. ​FIFA.com ​looks back at a groundbreaking tournament.




ut

Futsal's road to Lithuania mapped out




ut

Three cities set to host the FIFA Futsal World Cup Lithuania 2020™




ut

Jubilant Solo retain crown but Oceanian gap narrows




ut

RELIVE: FIFA Futsal World Cup Lithuania 2020™ Official Emblem Launch




ut

Official Emblem revealed for FIFA Futsal World Cup Lithuania 2020™  




ut

South American hopefuls seeking Lithuania berths




ut

Russia, Portugal, Spain and Kazakhstan secure Futsal World Cup returns




ut

South American quartet seal qualification to Lithuania 2020




ut

Cardenas sees Monterrey snatch bronze in shootout




ut

General view of play during the FIFA Futsal World Cup semi-final match

MEDELLIN, COLOMBIA - SEPTEMBER 27: General view of play during the FIFA Futsal World Cup semi-final match between Iran and Russia at Coliseo Ivan de Bedout on September 27, 2016 in Medellin, Colombia. (Photo by Jan Kruger - FIFA/FIFA via Getty Images)




ut

General view of play during the FIFA Futsal World Cup semi-final match

MEDELLIN, COLOMBIA - SEPTEMBER 27: General view of play during the FIFA Futsal World Cup semi-final match between Iran and Russia at Coliseo Ivan de Bedout on September 27, 2016 in Medellin, Colombia. (Photo by Jan Kruger - FIFA/FIFA via Getty Images)




ut

A general view of the Coliseo Ivan de Bedout

MEDELLIN, COLOMBIA - SEPTEMBER 27: A general view of the Coliseo Ivan de Bedout stadium during the FIFA Futsal World Cup Semi-Final match between Iran and Russia at Coliseo Ivan de Bedout stadium on September 27, 2016 in Medellin, Colombia. (Photo by Alex Caparros - FIFA/FIFA via Getty Images)




ut

Players of Russia huddle prior to the FIFA Futsal World Cup Group B match between Thailand and Russia

MEDELLIN, COLOMBIA - SEPTEMBER 10: Players of Russia huddle prior to the FIFA Futsal World Cup Group B match between Thailand and Russia at Coliseo Ivan de Bedout stadium on September 10, 2016 in Medellin, Colombia. (Photo by Alex Caparros - FIFA/FIFA via Getty Images)




ut

Players shake hand at the end of the match during the FIFA Futsal World Cup round of 16 match between Russia and Vietnam

MEDELLIN, COLOMBIA - SEPTEMBER 20: Players shake hand at the end of the match during the FIFA Futsal World Cup round of 16 match between Russia and Vietnam at Coliseo Ivan de Bedout on September 20, 2016 in Medellin, Colombia. (Photo by Jan Kruger - FIFA/FIFA via Getty Images)




ut

The Russian dressing room is seen ahead of the FIFA Futsal World Cup Quarter-Final match between Russia and Spain

CALI, COLOMBIA - SEPTEMBER 24: The Russian dressing room is seen ahead of the FIFA Futsal World Cup Quarter-Final match between Russia and Spain at the Coliseo el Pueblo Stadium on September 24, 2016 in Cali, Colombia. (Photo by Ian MacNicol - FIFA/FIFA via Getty Images)




ut

The Stadium is seen prior to the FIFA Futsal World Cup Semi Final match between Argentina and Portugal

CALI, COLOMBIA - SEPTEMBER 28: The Stadium is seen prior to the FIFA Futsal World Cup Semi Final match between Argentina and Portugal at the Coliseo el Pueblo Stadium on September 28, 2016 in Cali, Colombia. (Photo by Ian MacNicol - FIFA/FIFA via Getty Images)




ut

Cristian Borruto of Argentina reacts after he scores

CALI, COLOMBIA - SEPTEMBER 28: Cristian Borruto of Argentina reacts after he scores during the FIFA Futsal World Cup Semi Final match between Argentina and Portugal at the Coliseo el Pueblo Stadium on September 28, 2016 in Cali, Colombia. (Photo by Ian MacNicol - FIFA/FIFA via Getty Images)




ut

Cristian Borruto (L) of Argentina scores the opening goal

Cristian Borruto (L) of Argentina scores the opening goal during the FIFA Futsal World Cup Semi-Final match between Argentina and Portugal at the Coliseo El Pueblo stadium on September 28, 2016 in Cali, Colombia. (Photo by Alex Caparros - FIFA/FIFA via Getty Images)




ut

Cristian Borruto (L) of Argentina celebrates with teammates

Cristian Borruto (L) of Argentina celebrates with teammates after scoring the opening goal during the FIFA Futsal World Cup Semi-Final match between Argentina and Portugal at the Coliseo El Pueblo stadium on September 28, 2016 in Cali, Colombia. (Photo by Alex Caparros - FIFA/FIFA via Getty Images)




ut

Cristian Borruto (L) of Argentina scores the opening goal

Cristian Borruto (L) of Argentina scores the opening goal during the FIFA Futsal World Cup Semi-Final match between Argentina and Portugal at the Coliseo El Pueblo stadium on September 28, 2016 in Cali, Colombia. (Photo by Alex Caparros - FIFA/FIFA via Getty Images)




ut

Argentina's Cristian Borruto (R) scores against Portugal

Argentina's Cristian Borruto (R) scores against Portugal during their Colombia 2016 FIFA Futsal World Cup match at the Coliseo El Pueblo stadium, in Cali, Colombia on September 28, 2016. / AFP / LUIS ROBAYO




ut

Cristian Borruto (3rd L) of Argentina celebrates with teammates

Cristian Borruto (3rd L) of Argentina celebrates with teammates after scoring the opening goal during the FIFA Futsal World Cup Semi-Final match between Argentina and Portugal at the Coliseo El Pueblo stadium on September 28, 2016 in Cali, Colombia. (Photo by Alex Caparros - FIFA/FIFA via Getty Images)




ut

Players of Argentina celebrate after the FIFA Futsal World Cup Semi-Final

Players of Argentina celebrate after the FIFA Futsal World Cup Semi-Final match between Argentina and Portugal at the Coliseo El Pueblo stadium on September 28, 2016 in Cali, Colombia. (Photo by Alex Caparros - FIFA/FIFA via Getty Images)




ut

Cristian Borruto (L) of Argentina protects the ball from Joao Matos (R)

Cristian Borruto (L) of Argentina protects the ball from Joao Matos (R) during the FIFA Futsal World Cup Semi-Final match between Argentina and Portugal at the Coliseo El Pueblo stadium on September 28, 2016 in Cali, Colombia. (Photo by Alex Caparros - FIFA/FIFA via Getty Images)




ut

Cristian Borruto #9 of Argentina takes a selfie photo with fans

BUCARAMANGA, COLOMBIA - SEPTEMBER 15: Cristian Borruto #9 of Argentina takes a selfie photo with fans after Group E match play between Argentina and the Solomon Islands in the 2016 FIFA Futsal World Cup at Coliseo Bicentenario on September 15, 2016 in Bucaramanga, Colombia. Argentina defeated Solomon Islands 7-3. (Photo by Victor Decolongon - FIFA/FIFA via Getty Images)




ut

Cristian Borruto of Argentina is seen in the tunnel

CALI, COLOMBIA - SEPTEMBER 28: Cristian Borruto of Argentina is seen in the tunnel during the FIFA Futsal World Cup Semi Final match between Argentina and Portugal at the Coliseo el Pueblo Stadium on September 28, 2016 in Cali, Colombia. (Photo by Ian MacNicol - FIFA/FIFA via Getty Images)




ut

Cristian Borruto of Argentina celebrates after he scores the opening goal

CALI, COLOMBIA - SEPTEMBER 28: Cristian Borruto of Argentina celebrates after he scores the opening goal during the FIFA Futsal World Cup Semi Final match between Argentina and Portugal at the Coliseo el Pueblo Stadium on September 28, 2016 in Cali, Colombia. (Photo by Ian MacNicol - FIFA/FIFA via Getty Images)




ut

Cristian Borruto of Argentina reacts after he scores against Portugal

CALI, COLOMBIA - SEPTEMBER 28: Cristian Borruto of Argentina reacts after he scores during the FIFA Futsal World Cup Semi Final match between Argentina and Portugal at the Coliseo el Pueblo Stadium on September 28, 2016 in Cali, Colombia. (Photo by Ian MacNicol - FIFA/FIFA via Getty Images)




ut

Argentina are seen prior to the FIFA Futsal World Cup Semi Final

CALI, COLOMBIA - SEPTEMBER 28: Argentina are seen prior to the FIFA Futsal World Cup Semi Final match between Argentina and Portugal at the Coliseo el Pueblo Stadium on September 28, 2016 in Cali, Colombia. (Photo by Ian MacNicol - FIFA/FIFA via Getty Images)




ut

Fernando Gutiérrez Lumbreras looks on

CALI, COLOMBIA - SEPTEMBER 10: Fernando Gutiérrez Lumbreras  looks on during the Group A match between Colombia and Portugal during the FIFA Futsal World Cup at the Coliseo el Pueblo Stadium on September 10, 2016 in Cali, Colombia. (Photo by Ian MacNicol - FIFA/FIFA via Getty Images)