-
Notifications
You must be signed in to change notification settings - Fork 73
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 this library in React project #157
Comments
You can customize a component and instantiate |
Issues while running in Reactjs: TypeError: Cannot read properties of null (reading 'determineDimensions') |
Issue in referencing the canvas |
anyone get this to work in svelte? |
Here's a component I created that works with similes-drawer. import React, { useRef, useEffect } from "react";
import SmilesDrawer from "smiles-drawer";
const USE_SVG = true;
const SETTINGS = {
width: 800,
height: 400,
};
const SmileDrawerContainer = ({ smilesStr }: { smilesStr: string }) => {
if (USE_SVG) {
// SVG version (versions: <=2.0.3 and 2.1.7)
const svgRef = useRef<SVGElement>(null);
let drawer = new SmilesDrawer.SvgDrawer(SETTINGS);
useEffect(() => {
SmilesDrawer.parse(smilesStr, function (tree: any) {
drawer.draw(tree, "structure-svg", "light");
});
}, []);
return (
<div>
<svg id="structure-svg"></svg>
</div>
);
} else {
// Canvas version (versions: <=2.0.3 only)
const canvasRef = useRef<HTMLCanvasElement>(null);
let drawer = new SmilesDrawer.Drawer(SETTINGS);
useEffect(() => {
SmilesDrawer.parse(smilesStr, function (tree: any) {
drawer.draw(tree, "structure-canvas", "light");
});
}, []);
return (
<div>
<canvas
className="relative"
id="structure-canvas"
ref={canvasRef}
width={"800px"}
height={"400px"}
/>
</div>
);
}
};
export default SmileDrawerContainer; |
Hi, how can I use this library in my React Project?
The text was updated successfully, but these errors were encountered: