-
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use in a React project? #1
Comments
I haven't tested it at all, but in theory, I've kept everything as compatible as possible to React. It should be as easy as aliasing the |
Ok. I'll try that. Thanks. |
@hadim this is how you can do it, it's a React wrapper for preact component credit goes to this author https://swizec.com/blog/seamlessly-render-preact-component-react-project/swizec/8224
|
@mberd I don't think it's necessary to create a wrapper like that. In doing so, you'll need to bundle Preact as well as React in your webapp which is a little too much. Does it not work if you alias |
@yishn first - big thanks for writing this :) this is the error i am getting Warning: The component appears to have a render method, but doesn't extend React.Component. This is likely to cause errors. Change Goban to extend React.Component instead. and I don't know/couldn't find how to use alias in webpack... :( |
fixed
now only this warning: Warning: Unsafe legacy lifecycles will not be called for components using new component APIs. Goban uses getDerivedStateFromProps() but also contains the following legacy lifecycles: The above lifecycles should be removed. Learn more about this warning here: |
Exactly, you have to alias |
I'm trying to make this work on NextJS but haven't been able to so far. Does anyone have a tip? The core of the issue I'm having I believe is this:
This is apparently because Preact didn't use I'm having to use a
Here's what I have on my // import { h } from "preact";
import { Goban } from "@sabaki/shudan";
export function CustomComponent() {
return (
// @ts-ignore
<Goban
vertexSize={24}
signMap={[
[0, 0],
[0, 0],
]}
/>
);
}
export default function Home() {
return (
<>
<CustomComponent />
</>
);
} My /** @type {import('next').NextConfig} */
const nextConfig = {
webpack: {
resolve: {
alias: {
preact: "react",
"preact/hooks": "react", // I have tried it with or without this line
},
extensions: ["*", ".js", ".jsx", ".ts", ".tsx"],
},
},
};
module.exports = nextConfig; I'm using NextJS 14, here are the key dependencies on my {
"@sabaki/shudan": "^1.7.1",
"next": "14.0.2",
"preact": "^10.19.2",
} |
Here's an first attempt (I've actually tried many variations of it already): @psygo/embed_shudan If anyone manages to get a template going, I would greatly appreciate it. |
I got it working with vite in my vite.config.js with export default defineConfig({ I think the order of those aliases matters. Let the record reflect I'm not very knowledgeable about JS at all. |
@andrew-taylor-2 could you maybe share a template repo? |
How hard would it be to use this lib in a React project? I found a lot of examples to use React components into Preact projects but the other way...
The text was updated successfully, but these errors were encountered: