• Stars
    star
    785
  • Rank 57,957 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 4 years ago
  • Updated 6 months ago

Reviews

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

Repository Details

โƒ A react null renderer

Size Version Downloads Twitter Discord

There are legitimate use cases for null components or logical components.

A component has a lifecycle, local state, packs side-effects into useEffect, memoizes calculations in useMemo, orchestrates async ops with suspense, communicates via context, maintains fast response with concurrency. And of course โ€” the entire React ecosystem is available.

Nothing to see here ...

Quite so. This package allows you to bring React's high-level component abstraction to Node or wherever you need it. Why not manage your REST endpoints like routes on the client, users as components with mount/unmount lifecycles, self-contained separation of concern, and clean side effects? Suspense for requests, etc.

You can try a small demo here: https://codesandbox.io/s/react-nil-mvpry

How does it work?

The following renders a logical component without a view, it renders nothing, but it has a real lifecycle and is managed by React regardless.

import * as React from 'react'
import { render } from 'react-nil'

function Foo() {
  const [active, set] = React.useState(false)
  React.useEffect(() => void setInterval(() => set((a) => !a), 1000), [])

  // false, true, ...
  console.log(active)
}

render(<Foo />)

We can take this further by rendering made-up elements that get returned as a reactive JSON tree from render.

You can take a snapshot for testing via act which will wait for effects and suspense to finish.

import * as React from 'react'
import { act, render } from 'react-nil'

function Test(props) {
  const [value, setValue] = React.useState(-1)
  React.useEffect(() => setValue(Date.now()), [])
  return <timestamp value={value} />
}

const container = await act(async () => render(<Test />))

// { type: 'timestamp', props: { value: number }, children: [] }
console.log(container.head)

More Repositories

1

zustand

๐Ÿป Bear necessities for state management in React
TypeScript
45,348
star
2

react-spring

โœŒ๏ธ A spring physics based React animation library
TypeScript
27,857
star
3

react-three-fiber

๐Ÿ‡จ๐Ÿ‡ญ A React renderer for Three.js
TypeScript
26,202
star
4

jotai

๐Ÿ‘ป Primitive and flexible state management for React
TypeScript
18,007
star
5

use-gesture

๐Ÿ‘‡Bread n butter utility for component-tied mouse/touch gestures in React and Vanilla Javascript.
TypeScript
8,861
star
6

valtio

๐Ÿ’Š Valtio makes proxy-state simple for React and Vanilla
TypeScript
8,738
star
7

drei

๐Ÿฅ‰ useful helpers for react-three-fiber
JavaScript
8,042
star
8

leva

๐ŸŒ‹ React-first components GUI
TypeScript
4,825
star
9

gltfjsx

๐ŸŽฎ Turns GLTFs into JSX components
JavaScript
4,251
star
10

use-cannon

๐Ÿ‘‹๐Ÿ’ฃ physics based hooks for @react-three/fiber
TypeScript
2,700
star
11

react-three-next

React Three Fiber, Threejs, Nextjs starter
JavaScript
2,370
star
12

postprocessing

A post processing library for three.js.
JavaScript
2,263
star
13

racing-game

๐ŸŽ Open source racing game developed by everyone willing
TypeScript
2,120
star
14

xr

๐Ÿคณ VR/AR for react-three-fiber
TypeScript
2,051
star
15

uikit

๐ŸŽจ user interfaces for react-three-fiber
TypeScript
2,048
star
16

react-three-flex

๐Ÿ’ช๐Ÿ“ฆ Flexbox for react-three-fiber
TypeScript
1,640
star
17

suspend-react

๐Ÿšฅ Async/await for React components
TypeScript
1,358
star
18

react-postprocessing

๐Ÿ“ฌ postprocessing for react-three-fiber
JavaScript
1,074
star
19

detect-gpu

Classifies GPUs based on their 3D rendering benchmark score allowing the developer to provide sensible default settings for graphically intensive applications.
TypeScript
1,017
star
20

react-three-rapier

๐Ÿคบ Rapier physics in React
TypeScript
1,005
star
21

lamina

๐Ÿฐ An extensible, layer based shader material for ThreeJS
TypeScript
1,005
star
22

its-fine

๐Ÿถ๐Ÿ”ฅ A collection of escape hatches for React.
TypeScript
978
star
23

react-use-measure

๐Ÿ™Œ Utility to measure view bounds
TypeScript
832
star
24

maath

๐Ÿชถ Math helpers for the rest of us
TypeScript
783
star
25

threejs-journey

โš›๏ธ Bruno Simons journey demos in React
TypeScript
718
star
26

three-stdlib

๐Ÿ“š Stand-alone library of threejs examples designed to run without transpilation in node & browser
JavaScript
651
star
27

react-three-editor

๐Ÿ”Œ A one of a kind scene editor that writes changes back into your code
TypeScript
615
star
28

react-three-a11y

โ™ฟ๏ธ Accessibility tools for React Three Fiber
TypeScript
534
star
29

ecctrl

๐Ÿ•น๏ธ A floating rigibody character controller
TypeScript
498
star
30

react-three-offscreen

๐Ÿ“บ Offscreen worker canvas for react-three-fiber
TypeScript
443
star
31

react-zdog

โšก๏ธ๐Ÿถ React bindings for zdog
JavaScript
441
star
32

drei-vanilla

๐Ÿฆ drei-inspired helpers for threejs
TypeScript
436
star
33

use-asset

๐Ÿ“ฆ A promise caching strategy for React Suspense
TypeScript
413
star
34

tunnel-rat

๐Ÿ€ Non gratum anus rodentum
TypeScript
329
star
35

react-three-csg

๐Ÿšง Constructive solid geometry for React
TypeScript
264
star
36

react-three-lgl

๐Ÿ”† A React abstraction for the LGL Raycaster
TypeScript
262
star
37

gltf-react-three

Convert GLTF files to React Three Fiber Components
JavaScript
258
star
38

market

๐Ÿ“ฆ Download CC0 assets ready to use in your next 3D Project
JavaScript
250
star
39

component-material

๐Ÿงฉ Compose modular materials in React
TypeScript
160
star
40

env

๐Ÿ’„ An app to create, edit, and preview HDR environment maps in the browser
TypeScript
151
star
41

react-ogl

๐Ÿฆด A barebones react renderer for ogl.
TypeScript
150
star
42

use-p2

๐Ÿ‘‹๐Ÿ’ฃ 2d physics hooks for @react-three/fiber
TypeScript
144
star
43

react-spring-examples

JavaScript
139
star
44

react-three-gpu-pathtracer

โšก๏ธ A React abstraction for the popular three-gpu-pathtracer
TypeScript
132
star
45

react-three-lightmap

In-browser lightmap/AO baker for react-three-fiber and ThreeJS
TypeScript
127
star
46

cannon-es-debugger

Wireframe debugger for use with cannon-es https://github.com/react-spring/cannon-es
HTML
102
star
47

rafz

๐Ÿ’ One loop to frame them all.
TypeScript
96
star
48

docs

๐Ÿ–จ๏ธ mdx documentation generator for `pmndrs/*/docs` folders
TypeScript
91
star
49

assets

๐Ÿ“ฆ Importable base64 encoded CC0 assets
Makefile
91
star
50

swc-jotai

Rust
88
star
51

react-three-jolt

โšก Jolt physics in React
TypeScript
84
star
52

react-three-scissor

โœ‚ Multiple scenes, one canvas! WebGL Scissoring implementation for React Three Fiber.
TypeScript
79
star
53

eslint-plugin-valtio

An eslint plugin for better valtio experience
JavaScript
74
star
54

react-three-babel

๐Ÿ› A Babel plugin that automatically builds the extend catalogue of known native Three.js elements
TypeScript
60
star
55

react-spring.io

โœŒ๏ธ A spring physics based React animation library
TypeScript
56
star
56

r3f-website

Website for React Three Fiber
JavaScript
27
star
57

directed

A flexible, minimal scheduler written in TypeScript
TypeScript
24
star
58

market-assets

JavaScript
19
star
59

react-three-8thwall

JavaScript
17
star
60

drei-assets

JavaScript
16
star
61

discord

๐Ÿค– Poimandres Discord Bot
TypeScript
10
star
62

branding

TypeScript
7
star
63

market-assets-do

JavaScript
5
star
64

envinfo

Easily collect useful information for bug reports
JavaScript
4
star
65

leva-wg

1
star