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.

[enhancement] Stage could take the width & height of it's parent

See original GitHub issue

What

I see you have to pass a width & height value you to the Stage component, I’m wondering if instead we should be using a hook like react-use-measure where the canvas would be able to update and size itself correctly based on it’s parent. This could be a nicer developer experience as it’s something that I imagine, most people will implement themselves anyway.

How

I’m not sure how reactive Konva.Stage is and whether or not you’d have to destroy it to give it new dimensions. https://github.com/konvajs/react-konva/blob/672af98bf814a5fd261652cd5bd25ac864c7b6d9/src/ReactKonvaCore.js#L56 But you could use the hook to call the width and height methods to update?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
lavrtoncommented, May 10, 2021

Well you already can do something like this just fine:

import useMeasure from 'react-use-measure'

function App() {
  const [ref, bounds] = useMeasure()
  return (
    <div ref={ref}>
      <Stage width={bounds.width> height={bounds.height} />
    </div>
  );
}
1reaction
lavrtoncommented, Aug 19, 2021

For that use case, I am usually using absolute position for stage, so its size doesn’t affect size of parent, so it doesn’t break flex flow.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exploring the Complexities of Width and Height in CSS
The width and height of an element gets super interesting with parent and child elements. Let's look at all the interesting quirks we...
Read more >
how a child can get the width / height of it's parent dynamically
example : if a parent has a width: 200 , the child's width should be width: 40 . and I want a way...
Read more >
How to Scale child like it was part of parent? - Unity Forum
My problem is that my parent width and height is based on very complicated UI aspect ratio fitters and custom scripts. So I...
Read more >
mask-size - CSS: Cascading Style Sheets - MDN Web Docs
The mask-size CSS property specifies the sizes of the mask images. ... To specify a size using width and height, you can supply...
Read more >
Steroids (for Parents) - Nemours KidsHealth
enlargement of the clitoris. What Else Can Happen? Besides the health risks, kids who use steroids without a prescription are breaking the law....
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