Skip to content

Instantly share code, notes, and snippets.

View ronal2do's full-sized avatar

Ronaldo Lima ronal2do

View GitHub Profile
@acdlite
acdlite / coordinating-async-react.md
Last active March 20, 2022 12:27
Demo: Coordinating async React with non-React views

Demo: Coordinating async React with non-React views

tl;dr I built a demo illustrating what it might look like to add async rendering to Facebook's commenting interface, while ensuring it appears on the screen simultaneous to the server-rendered story.

A key benefit of async rendering is that large updates don't block the main thread; instead, the work is spread out and performed during idle periods using cooperative scheduling.

But once you make something async, you introduce the possibility that things may appear on the screen at separate times. Especially when you're dealing with multiple UI frameworks, as is often the case at Facebook.

How do we solve this with React?

@acdlite
acdlite / Dataloader.js
Last active August 15, 2018 04:36
Idea for Dataloader component
// The `loader` prop is a Dataloader instance
// https://github.com/facebook/dataloader
class Dataloader extends React.Component {
state = {data: null, isLoaded: false};
componentWillMount() {
this.prefetchData(this.props);
}
componentWillReceiveProps(nextProps) {
if (this.props.id !== nextProps.id || this.props.loader !== nextProps.loader) {
this.setState({isLoaded: false});
@danielfttorres
danielfttorres / CreateStoryMutation.js
Last active November 1, 2017 17:12
Some stuff for help to make Relay Modern mutation updates
// @flow
import Relay, { graphql } from 'react-relay'
import { mutationCreateUpdater} from './mutationUpdater'
const mutation = graphql`
mutation createStoryMutation($input: CreateStoryInput!) {
createStory(input: $input) {
story {
id
@sibelius
sibelius / flow-redux.guideline.md
Created November 10, 2017 16:23
How to easily type Redux Props with Flow

How to easily type Redux Props with Flow

Add ExtractReturn helper

// https://hackernoon.com/redux-flow-type-getting-the-maximum-benefit-from-the-fewest-key-strokes-5c006c54ec87
// https://github.com/facebook/flow/issues/4002
// eslint-disable-next-line no-unused-vars
type _ExtractReturn<B, F: (...args: any[]) => B> = B;
export type ExtractReturn = _ExtractReturn&lt;*, F&gt;;
@mike-marcacci
mike-marcacci / Root.js
Last active July 10, 2019 13:18
Relay Modern SSR
// @flow
import React, { Component } from "react";
import PropTypes from "prop-types";
import App from "./components/App";
type Props = {
environment: *,
queryTracker?: *
};
@jordanmkoncz
jordanmkoncz / .react-navigation iOS 11 Navigation Bar with Large Title
Last active May 9, 2022 16:21
react-navigation iOS 11 Navigation Bar with Large Title
#
@wbyoung
wbyoung / environment.js
Created July 23, 2018 17:59
Relay environment while exploring deferred queries
/* @flow */
import {
forOwn,
size,
get,
transform,
noop,
} from 'lodash';
@sibelius
sibelius / removeCascadeMongoose.js
Created July 25, 2018 12:34
Remove cascade for mongoose
import mongoose from 'mongoose';
import connectDatabase from '../src/common/database';
// this is needed to load all models in mongoose.models
// eslint-disable-next-line
import * as M from '../src/models';
const removeCascade = async (modelName: string, _id: string) => {
const modelNames = Object.keys(mongoose.models);

Time Travel Debugging

Time Travel refers to the ability to record a tab and later replay it ([WebReplay][wrr]). The technology is useful for local development, where you might want to:

  • pause and step forwards or backwards
  • pause and rewind to a prior state
  • rewind to the time a console message was logged
  • rewind to the time an element had a certain style or layout
  • rewind to the time a network asset loaded
@LFSCamargo
LFSCamargo / AnimatedGate.tsx
Created May 30, 2019 01:48
Animated Twitter LaunchScreen
import * as React from 'react'
import { Animated, Easing, StatusBar, MaskedViewIOS, View, ViewStyle } from 'react-native'
import icons from '../../icons'
import lightTheme from '../../config/theme'
interface Props {
bootstraped: boolean
}
const AnimatedGate: React.FunctionComponent<Props> = (props) => {