• Stars
    star
    445
  • Rank 98,085 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Render async Stateless Functional Components in React

async-reactor

Render async Stateless Functional Components

Installation

npm install --save async-reactor

Usage

asyncReactor(component: Function, loader?: Component, error?: Component): Component
name type description
component Function (async) The async component you want to render
loader (optionnal) Component Will be shown until the first component renders
error (optionnal) Component Will be shown when an error occurred

The returned value is a regular Component.

Examples

This examples are exporting a regular React component. You can integrate it into an existing application or render it on the page.

See more examples here

Using code splitting

import React from 'react'
import {asyncReactor} from 'async-reactor';

function Loader() {
  return (
    <b>Loading ...</b>
  );
}

async function Time() {
  const moment = await import('moment');
  const time = moment();

  return (
    <div>
      {time.format('MM-DD-YYYY')}
    </div>
  );
}

export default asyncReactor(Time, Loader);

Using fetch

import React from 'react';
import {asyncReactor} from 'async-reactor';

function Loader() {

  return (
    <h2>Loading ...</h2>
  );
}

async function AsyncPosts() {
  const data = await fetch('https://jsonplaceholder.typicode.com/posts');
  const posts = await data.json();

  return (
    <ul>
      {posts.map((x) => <li key={x.id}>{x.title}</li>)}
    </ul>
  );
}

export default asyncReactor(AsyncPosts, Loader);

More Repositories

1

webassemblyjs

Toolchain for WebAssembly
JavaScript
776
star
2

babel-plugin-transform-scala-lambda

Enable Scala lambda style
JavaScript
54
star
3

img-color-worker

Retrieve the dominant color of a PNG or JPEG image
JavaScript
46
star
4

c-webpack-demo

Just import c code in your JavaScript project
JavaScript
39
star
5

holyc

An easy to use C++ to WASM compiler (Highly-experimental)
JavaScript
37
star
6

wasm-coredump

Monorepo for generating, parsing, debugging WebAssembly coredump
Rust
32
star
7

acorn-import-attributes

Support for import assertions in acorn
JavaScript
22
star
8

charcodes

Char codes constants and AOT transform (used in Babel).
JavaScript
21
star
9

webassembly-feature

Test if a WebAssembly feature is supported
JavaScript
17
star
10

kv-backup

Copy the content of a Workers KV locally
Python
14
star
11

wasmgdb

Tool for debugging WebAssembly (like gdb).
Rust
12
star
12

inline-wast

Inline WebAssembly in your JavaScript
JavaScript
11
star
13

rewrite-3d-party

Get rid of 3rd party
JavaScript
10
star
14

wasm-edit

Edit and instrument already compiled Wasm binaries
Rust
10
star
15

unmarshaller

Toolbox for configuration
JavaScript
10
star
16

wasm-custom-section

Rust
10
star
17

wasm-coredump-format

Coredump Format for WebAssembly
9
star
18

react-eu-hackathon

JavaScript
7
star
19

sqlite-rs

decoder, encoder and tools for SQLite in Rust
Rust
7
star
20

svg-to-png-worker

SVG to PNG converter in Cloudflare Workers
Rust
5
star
21

simple-typechecker

simple typechecker
JavaScript
5
star
22

wasm-dce

Eliminate unused functions in your WASM binary
JavaScript
5
star
23

Fibonacci-forth

The Fibonacci sequence using Forth language with only two words
Forth
5
star
24

wasm-gen

Generates Wasm modules
Rust
4
star
25

redis-proxy

Nothing to see here
Go
4
star
26

WebPageTest-proxy

Proxy more WebPageTest features
JavaScript
4
star
27

compose-filters

https://twitter.com/alexandereardon/status/905955091638837251
JavaScript
4
star
28

babel-plugin-example

JavaScript
4
star
29

triton-rs

Rust bindings to the Triton Inference Server
Rust
4
star
30

js-to-native

Compile JS to native (unfinished)
JavaScript
3
star
31

Paypal-ipn-SDK

A simple way to implement PayPal IPN payments (updated)
PHP
3
star
32

babel-preset-jsfuck

Transforms your code into JSFuck
JavaScript
3
star
33

worker-template-rewrite-proxy

JavaScript
3
star
34

rollup-plugin-wasm

Rollup plugin for importing WebAssembly modules (using streaming)
JavaScript
3
star
35

webassembly-types

Better types for interacting with WebAssembly
JavaScript
3
star
36

demo-node-wasm-coredump

JavaScript
3
star
37

cancellable-promise-rs

Rust
2
star
38

wrangler-js

Nothing to see here.
JavaScript
2
star
39

wrangler-js-demo

JavaScript
2
star
40

falias

When it's time to fuzzy-search into your bash aliases and functions
Shell
2
star
41

Dockerfiles

Shell
2
star
42

CNED-MOOC

Programme accessibilité - Modèle MOOC Wikiversité
JavaScript
2
star
43

babel-plugin-immutable-const

Freeze object using const declaration
JavaScript
2
star
44

asc-wasm

Generate Wasm modules in AssemblyScript
TypeScript
2
star
45

node-loader-demo

JavaScript
2
star
46

schaloop

Approach for event-driven Golang application
Go
1
star
47

haskell-bc

[WIP] Haskell implementation of Unix bc
Haskell
1
star
48

babel-preset-reasonml

Babel preset for @reasonml
JavaScript
1
star
49

better-errors

Better errors
Go
1
star
50

CSS-as-React-component

Transform CSS code into React components
JavaScript
1
star
51

monadic-logger

Implementation example
JavaScript
1
star
52

CRDT-test

JavaScript
1
star
53

link-to-babel-repl-generator

Generate links to the Babel REPL
JavaScript
1
star
54

HiddenFiles

Permet de cacher une archive (RAR) dans une image (BMP, GIF et le format par défault JPG).
PHP
1
star
55

hackschool

JavaScript
1
star
56

fableconf-2017-material

Material for my talk at Fableconf 2017
JavaScript
1
star
57

Nmap

Nmap clone written in Scala
Scala
1
star
58

es-pdf-ingest

ElasticSearch PDF ingestor
Shell
1
star
59

mamacro

JavaScript
1
star
60

Symfony2-password-encoder

Obviously more secure that plaintext passwords
1
star
61

esi-cf-workers

Edge Side Includes (ESI) for Cloudflare Workers
JavaScript
1
star
62

sieve2workers

Convert a Sieve program into a Cloudflare Workers for Cloudflare Email Routing.
Rust
1
star