question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

opacity property in <Rect/> occur error

See original GitHub issue
  • Hello, I’m using your React-Konva library and find it super easy and helpful!
  • I just have 1 issue atm. everything worked fine until I add opacity={opacity} on Rect component.
  • I also tried opacity="0.8"(which caused type error) and opacity={0.8} but it also caused exact same error. So I’m wondering is this my problem or konva opacity problem!
  • I’d appreciate if you also let me know what I could do to fix it!
  • FYL) rgba() worked fine to add opacity! But I’m asking just in case I’m missng something about opacity propery or any possible issues

Thanks a lot!

[Error] 스크린샷 2022-07-04 오후 3 11 07

[My Code]

const VerticallyDraggableDiv: React.FC<VerticallyDraggableDivProps> = ({
  x,
  y,
  width,
  height,
  handleDragging,
  handleDragEnd,
  borderColor,
  backgroundColor,
  text,
  fontColor,
  idx,
}) => {
  const [opacity, setOpacity] = useState(0.5);
  return (
    <Group
      x={x}
      y={y}
      draggable
      dragBoundFunc={(pos) => handleDragging({ pos })}
      onDragEnd={idx !== undefined && handleDragEnd ? (e) => handleDragEnd({ e, idx }) : undefined}
    >
      <Rect
        width={width}
        height={height}
        stroke={borderColor}
        strokeWidth={0.3}
        fill={backgroundColor}
        text={text}
        cornerRadius={2}
        opacity={opacity} // opacity is here!
      />
      <Text
        width={width}
        height={height}
        fill={fontColor}
        fontSize={20}
        align="center"
        verticalAlign="middle"
        text={text}
      />
    </Group>
  );
};

export default VerticallyDraggableDiv;

+Also my react-konva and konva versions are like below

    "konva": "^8.3.6",
    "react-konva": "^17.0.2-6",`

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
lavrtoncommented, Jul 12, 2022

I don’t know. This is why I need a demo. You don’t need to give access to your app or copy its code. Just make a small, reproducible demo. Simple stage with one rectangle. And set properties in a way when error is visible.

0reactions
lavrtoncommented, Nov 17, 2022

Looks like Konva can’t handle the case, when size of the stage is 0. As a workaround, set minimum to 1.

const [ref, { width, height }] = useMeasure();
<Stage width={Math.max(1, width)} height={Math.max(1, height)}>

Closing, as extreme edge case. But I am happy to apply Pull Request to handle zero stage size correctly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Property 'opacity' does not exist on type 'IntrinsicAttributes ...
Property 'opacity' does not exist on type 'IntrinsicAttributes' throwing and error for view Opacity in React native.
Read more >
Opacity properties should affect nothing but opacity · Issue #264
In some cases (in eg SVG 1 or 2 or CSS), setting/changing opacity changes the stacking order / changes which items overlap which....
Read more >
Opacity Properties In Components - Adobe Support Community
Solved: I've set up my mobile app design that has a lot of buttons. The button shape/style is a component (cloud-based in case...
Read more >
Fabric.js | Rect opacity Property - GeeksforGeeks
In this article, we are going to see how to set the opacity of a rectangle canvas using FabricJS. The canvas rectangle means...
Read more >
Masks - Figma Help Center
Note: If all layers being masked are hidden or have 0% opacity, then the object's mask outlines won't appear. Use shape outlines to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found