-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor!: v1, add types, react 18 support (#10)
- Loading branch information
1 parent
497fbe9
commit 4efdf62
Showing
18 changed files
with
863 additions
and
4,984 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: CI | ||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
branches: [master] | ||
|
||
jobs: | ||
build-test-lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
|
||
- name: Check build health | ||
run: yarn build | ||
|
||
- name: Run tests | ||
run: yarn test --silent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,12 @@ | ||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/ | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# pnpm lock | ||
|
||
pnpm-lock.yaml | ||
|
||
node_modules | ||
dist | ||
|
||
# Editor directories and files | ||
.idea | ||
.vscode | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020-2022 Poimandres | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
[](https://bundlephobia.com/package/react-nil) | ||
[](https://npmjs.com/package/react-nil) | ||
[](https://npmjs.com/package/react-nil) | ||
[](https://twitter.com/pmndrs) | ||
[](https://discord.gg/poimandres) | ||
|
||
<p align="left"> | ||
<a id="cover" href="#cover"> | ||
<picture> | ||
<source media="(prefers-color-scheme: dark)" srcset=".github/dark.svg"> | ||
<img style="white-space:pre-wrap" alt="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." src=".github/light.svg"> | ||
</picture> | ||
</a> | ||
</p> | ||
|
||
#### 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? | ||
|
||
```jsx | ||
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), []) | ||
console.log(active) | ||
|
||
// This is a logical component without a view, it renders nothing, | ||
// but it has a real lifecycle and is managed by React regardless. | ||
return null | ||
} | ||
|
||
render(<Foo />) | ||
``` |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,55 @@ | ||
{ | ||
"name": "react-nil", | ||
"version": "0.0.3", | ||
"description": "react null renderer, a react custom renderer that renders nothing but logical components", | ||
"main": "dist/index.cjs.js", | ||
"module": "dist/index.js", | ||
"sideEffects": false, | ||
"scripts": { | ||
"build": "rollup -c", | ||
"prepublishOnly": "npm run build", | ||
"test": "echo no tests yet" | ||
}, | ||
"version": "1.0.0", | ||
"description": "react nil, a react custom renderer that renders nothing but logical components", | ||
"keywords": [ | ||
"react", | ||
"null", | ||
"nil", | ||
"renderer", | ||
"node" | ||
], | ||
"author": "Paul Henschel", | ||
"author": "Paul Henschel (https://github.com/drcmda)", | ||
"maintainers": [ | ||
"Gianmarco Simone (https://github.com/gsimone)", | ||
"Stephen Corwin (https://github.com/stephencorwin)", | ||
"Cody Bennett (https://github.com/codyjasonbennett)" | ||
], | ||
"homepage": "https://github.com/pmndrs/react-nil", | ||
"repository": "https://github.com/pmndrs/react-nil", | ||
"license": "MIT", | ||
"files": [ | ||
"dist/*", | ||
"src/*" | ||
], | ||
"types": "./dist/index.d.ts", | ||
"main": "./dist/index.js", | ||
"module": "./dist/index.mjs", | ||
"exports": { | ||
"types": "./dist/index.d.ts", | ||
"require": "./dist/index.js", | ||
"import": "./dist/index.mjs" | ||
}, | ||
"sideEffects": false, | ||
"devDependencies": { | ||
"@ampproject/rollup-plugin-closure-compiler": "^0.26.0", | ||
"@babel/core": "7.11.0", | ||
"@babel/plugin-proposal-class-properties": "^7.10.4", | ||
"@babel/plugin-transform-modules-commonjs": "7.10.4", | ||
"@babel/plugin-transform-parameters": "7.10.5", | ||
"@babel/plugin-transform-runtime": "7.11.0", | ||
"@babel/plugin-transform-template-literals": "7.10.5", | ||
"@babel/preset-env": "7.11.0", | ||
"@babel/preset-react": "7.10.4", | ||
"@babel/preset-typescript": "^7.10.4", | ||
"@rollup/plugin-babel": "^5.2.0", | ||
"@rollup/plugin-commonjs": "^15.0.0", | ||
"@rollup/plugin-json": "^4.1.0", | ||
"@rollup/plugin-node-resolve": "^9.0.0", | ||
"husky": "^4.2.5", | ||
"lint-staged": "^10.2.11", | ||
"prettier": "^2.0.5", | ||
"react": "^16.13.1", | ||
"@types/node": "^18.7.14", | ||
"@types/react": "^18.0.17", | ||
"react": "^18.2.0", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.26.10", | ||
"rollup-plugin-size-snapshot": "^0.12.0", | ||
"rollup-plugin-terser": "^7.0.2" | ||
"suspend-react": "^0.0.8", | ||
"typescript": "^4.7.4", | ||
"vite": "^3.0.9", | ||
"vitest": "^0.22.1" | ||
}, | ||
"dependencies": { | ||
"react-reconciler": "^0.25.1", | ||
"scheduler": "^0.20.2" | ||
"@types/react-reconciler": "^0.26.7", | ||
"react-reconciler": "^0.27.0" | ||
}, | ||
"peerDependencies": { | ||
"react": ">=16" | ||
"react": ">=18.0" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged" | ||
} | ||
}, | ||
"lint-staged": { | ||
"*.{js,jsx,ts,tsx}": [ | ||
"eslint --fix" | ||
] | ||
"scripts": { | ||
"build": "rimraf dist && vite build && tsc", | ||
"test": "vitest run" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.