How to use svg imported from React Component with use-image in konva?
I try import svg from Component but it's not working any way and it's not return any error. Same svg code imported from .svg file works good but i want to pass props to show in svg so i have to do this in this way. :)
Stamp.js
const Stamp = () => {
return (
<svg width="120" height="120" xmlns="http://www.w3.org/2000/svg">
<rect x="0" y="0" width="120" height="120" />
</svg>
);
};
export default Stamp;
Canvas.js
import useImage from 'use-image';
import Stamp from 'components/Stamp';
const Canvas = () => {
const PlaceStamp = () => {
const [image] = useImage(Stamp);
return <Image image={image} x={position.x} y={position.y} />;
};
return (
<Stage
width={width}
height={height}
ref={konvaRef}
onClick={() => {
handleClick();
IsDirty(true);
}}
onTap={() => {
handleClick();
IsDirty(true);
}}>
<Layer>
{dirty && <PlaceStamp />}
</Layer>
</Stage>
)
}