preact-react-reconciler
v0.0.1
Published
Turn preact into a react reconciler.
Readme
preact-react-reconciler
Who needs a bundler alias? preact-react-reconciler lets you render unmodified code that uses the real react package under Preact by using Preact option hooks to implement React's reconciler API! You can even use it along with react-dom on the same page, with the same copy of react, at the same time!
import { useCallback, useState } from "react";
import * as reactDOM from "react-dom/client";
import "preact-react-reconciler"; // enables interop!
import * as preact from "preact";
function Counter() {
const [count, setCount] = useState(0);
const onClick = useCallback(() => {
setCount(count + 1);
}, [count]);
return (
<>
<p>
Clicks: {count} <button onClick={onClick}>Increment</button>
</p>
<pre>{new Error().stack}</pre>
</>
);
}
preact.render(<Counter />, document.getElementById("preact-app")!);
reactDOM.createRoot(document.getElementById("react-app")!).render(<Counter />);