Giter Club home page Giter Club logo

preact-reconciler's Introduction

Size Version Downloads

preact-reconciler

Custom renderers for Preact in <1KB.

This package implements react-reconciler which allows for custom renderers to be implemented and shared between Preact and React such as @react-three/fiber.

import { render } from 'preact'
import { Canvas } from '@react-three/fiber'
import { OrbitControls } from '@react-three/drei'

// This is the same as ReactDOM.createRoot(root).render(...) with preact/compat
render(
  <Canvas>
    <OrbitControls />
    <mesh>
      <boxGeometry />
      <meshNormalMaterial />
    </mesh>
  </Canvas>,
  root,
)

Installation

To get started, you'll only need preact and preact-reconciler. No need to install react or react-dom.

npm install preact preact-reconciler
yarn add preact preact-reconciler
pnpm add preact preact-reconciler

With your choice of tooling, alias react, react-dom, and its dependencies.

const resolve = {
  alias: {
    react: 'preact/compat',
    'react-dom': 'preact/compat',
    'react-reconciler': 'preact-reconciler',
  },
}

// vite.config.js
export default { resolve }

// webpack.config.js
module.exports = { resolve }

// next.config.js (webpackFinal for .storybook/main.js)
module.exports = {
  webpack(config) {
    Object.assign(config.resolve.alias, resolve.alias)
    return config
  },
}

preact-reconciler's People

Contributors

codyjasonbennett avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

preact-reconciler's Issues

Doesn't work with preact v10.16.0

It seems to be broken to me with preact v10.16.0 (v10.15.0 works fine).

My package.json:

{
  "name": "0x-protein",
  "version": "0.0.1",
  "description": "Protein vis.",
  "files": [
    "dist"
  ],
  "sideEffects": false,
  "devDependencies": {
    "@preact/preset-vite": "^2.5.0",
    "typescript": "^4.9.5",
    "vite": "^4.1.4"
  },
  "peerDependencies": {
    "preact": ">=10"
  },
  "scripts": {
    "dev": "vite",
    "build": "vite build && tsc"
  },
  "dependencies": {
    "@react-three/cannon": "^6.5.2",
    "@react-three/drei": "^9.79.0",
    "@react-three/fiber": "^8.13.5",
    "preact": "^10.13.0",
    "preact-reconciler": "^0.1.6",
    "three": "^0.154.0"
  }
}

Error log from the browser:

debug.js:94 Uncaught TypeError: Cannot read properties of null (reading 'b')
    at u.insertBefore (index.mjs?v=91d08b7d:1:987)
    at $ (children.js:297:13)
    at P (children.js:200:14)
    at L (index.js:234:4)
    at P (children.js:133:3)
    at L (index.js:234:4)
    at P (children.js:133:3)
    at L (index.js:234:4)
    at P (children.js:133:3)
    at L (index.js:234:4)
2index.mjs?v=91d08b7d:1 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'b')
    at u.insertBefore (index.mjs?v=91d08b7d:1:987)
    at $ (children.js:297:13)
    at P (children.js:200:14)
    at L (index.js:234:4)
    at P (children.js:133:3)
    at L (index.js:234:4)
    at P (children.js:133:3)
    at L (index.js:234:4)
    at P (children.js:133:3)
    at L (index.js:234:4)
    ```
    
    As far as I know, this usually happens when there are dupes of preact. I don't see where it's coming from.
    
    Huge kudos for the project! I'm working on a presentational website. And size optimizations are crucial.

Package content of 0.1.7 is empty on NPM

Thanks for your great work on this package! I've been searching for solutions about replacing a react custom renderer which depends on react-reconciler with preact, and this package is truly a great inspiration.

However I've noticed that the package content on npm of version 0.1.7, which was released recently, did not contain any JavaScript codes. The version 0.1.6 has no such problem.

I'm wondering if this was a mistake during npm publishing? It would be appreciated if you could have a look at this. :)

❯ curl -O -L https://registry.npmjs.org/preact-reconciler/-/preact-reconciler-0.1.7.tgz
❯ tar tvf preact-reconciler-0.1.7.tgz
drw-rw-rw-  0 0      0           0 Jul 19 21:02 package
-rw-rw-rw-  0 0      0        1069 Mar  5 03:05 package/LICENSE
-rw-rw-rw-  0 0      0        1894 Mar  6 08:01 package/README.md
-rw-rw-rw-  0 0      0        2024 Jul 19 21:03 package/package.json

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.