First, an exercise. Can we represent all of css with plain data? Let's try.
let redText = { color: 'red' };| const { concat, mapKeys, merge, uniq } = require('lodash'); | |
| /** | |
| * Tweaked from original by Mike Engel | |
| * https://github.com/jantimon/html-webpack-plugin/issues/782#issuecomment-331229728 | |
| * | |
| * Use this with multiple Webpack configurations that generate different builds | |
| * for modern and legacy browsers. But use the same instance of the plugin in both configurations. | |
| * | |
| * It keeps track of assets seen in each build configuration, and appends script tags for |
| import { Base64 } from 'js-base64' | |
| import { Op } from 'sequelize' | |
| import { fromGlobalId } from 'graphql-relay' | |
| // https://github.com/graphql/graphql-relay-js/issues/94#issuecomment-232410564 | |
| const effectiveOrder = ({ last }, orderBy) => { | |
| /* adds `id ASC` to end of `ORDER BY` if `id` is not already in the `ORDER BY` clause | |
| flips `ASC` to `DESC` (and vice-versa) if pagination arg `last` is defined | |
| */ |
| /** | |
| * Returns new object without specified properties. | |
| * @param {Array.<string>} keys | |
| * @param {Object.<string, *>} object | |
| * @returns {Object.<string, *>} | |
| */ | |
| const without = ( | |
| [ key, ...keys ] = [], | |
| { [key]: _, ...object } = {} | |
| ) => keys.length ? object : without(keys, object); |
| FROM ruby:2.4-alpine3.7 | |
| # Install dependencies: | |
| # - build-base: To ensure certain gems can be compiled | |
| # - nodejs: Compile assets | |
| # - postgresql-dev postgresql-client: Communicate with postgres through the postgres gem | |
| # - libxslt-dev libxml2-dev: Nokogiri native dependencies | |
| # - imagemagick: for image processing | |
| RUN apk --update add build-base nodejs tzdata postgresql-dev postgresql-client libxslt-dev libxml2-dev imagemagick |
All libraries have subtle rules that you have to follow for them to work well. Often these are implied and undocumented rules that you have to learn as you go. This is an attempt to document the rules of React renders. Ideally a type system could enforce it.
A number of methods in React are assumed to be "pure".
On classes that's the constructor, getDerivedStateFromProps, shouldComponentUpdate and render.
Note:
When this guide is more complete, the plan is to move it into Prepack documentation.
For now I put it out as a gist to gather initial feedback.
If you're building JavaScript apps, you might already be familiar with some tools that compile JavaScript code to equivalent JavaScript code:
| import React, { Component } from 'react'; | |
| import { Button, Text, View } from 'react-native'; | |
| import { RNCamera } from 'react-native-camera'; | |
| class ProductScanRNCamera extends Component { | |
| constructor(props) { | |
| super(props); | |
| this.camera = null; | |
| this.barcodeCodes = []; |
| import React from 'react'; | |
| import { filter } from 'graphql-anywhere'; | |
| import hoistNonReactStatic from 'hoist-non-react-statics'; | |
| /* | |
| * createFragmentContainer returns a component which expects props that match | |
| * WrappedComponent's fragment names, and provides data masking | |
| */ | |
| export default function createFragmentContainer(WrappedComponent) { |