Positioning Components on Render Relative to Unknown Size of Other ComponentsGet the height of a Component in ReactPosition absolute but relative to parentReactJS: Modeling Bi-Directional Infinite ScrollingFacebook React.js : how do you render statefull components on the server?How can I respond to the width of an auto-sized DOM element in React?Strategies for server-side rendering of asynchronously initialized React.js componentsReact: To know size of the element before it gets renderedWhat is the preferred design pattern to delay rendering of a component in React?Rendering React components from textDynamically rendering react componentsReact - Updating scroll position of parent component, setState or use a ref?

How can I place the product on a social media post better?

How to creep the reader out with what seems like a normal person?

Unexpected email from Yorkshire Bank

How would one muzzle a full grown polar bear in the 13th century?

Do I have to worry about players making “bad” choices on level up?

How can the Zone of Truth spell be defeated without the caster knowing?

Can someone publish a story that happened to you?

What route did the Hindenburg take when traveling from Germany to the U.S.?

French for 'It must be my imagination'?

Sci-fi book: portals appear in London and send a failed artist towards a designated path where he operate a giant superweapon

What do the phrase "Reeyan's seacrest" and the word "fraggle" mean in a sketch?

How to solve constants out of the internal energy equation?

Who is the Umpire in this picture?

How much cash can I safely carry into the USA and avoid civil forfeiture?

Examples of subgroups where it's nontrivial to show closure under multiplication?

What is the relationship between spectral sequences and obstruction theory?

a sore throat vs a strep throat vs strep throat

Why isn't the definition of absolute value applied when squaring a radical containing a variable?

How to reduce LED flash rate (frequency)

A Strange Latex Symbol

Are Boeing 737-800’s grounded?

Why does nature favour the Laplacian?

How come there are so many candidates for the 2020 Democratic party presidential nomination?

What are the potential pitfalls when using metals as a currency?



Positioning Components on Render Relative to Unknown Size of Other Components


Get the height of a Component in ReactPosition absolute but relative to parentReactJS: Modeling Bi-Directional Infinite ScrollingFacebook React.js : how do you render statefull components on the server?How can I respond to the width of an auto-sized DOM element in React?Strategies for server-side rendering of asynchronously initialized React.js componentsReact: To know size of the element before it gets renderedWhat is the preferred design pattern to delay rendering of a component in React?Rendering React components from textDynamically rendering react componentsReact - Updating scroll position of parent component, setState or use a ref?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I'm developing a Node JS App using Electron and rendering the UI using React.
Simply, the user enters print commands in a word-processor component on the left side of the UI, and React interperets those commands and renders the content connected to those commands in real-time on the right side of the UI.
For example, Render Text "X" at coordinates X1, Y1. Rendering this kind of command is simple to do by triggering a change in state when the user enters a new command, and updating the rendered view of the command with a draw(). However, I am having difficulty deciding the best way to handle a problem senario when (1) the command coordinate given is not absolute but instead is relative to a prior command rendered component, and (2) the relational component does not have a known size that can be determined without rendering it first (usually it contains text with various fonts and font-sizes and varying character content). I'm trying to figure out the best way to implement the draw() calls in a way that will get me an accurately rendered image without unnecessary additional draw commands for both the statically positioned and dynamically positioned components.



I have thought about inserting the unknown relational components directly into the DOM with javascript, finding the size and saving it for the render, then hiding/removing them, but realize that this is poor practice when using React because obfuscates the true state of the DOM.
I googled this problem, and found this topic on StackOverflow (Get the height of a Component in React) which discusses using the ref variable as a callback to re-render the UI once the size is known. However, I wasn't sure if this solution was out-dated (this post is 3 years old), or if this was a practical solution for my use case since the rendered view on the right side is constantly changing as the user enters input on the command side of the UI instead of rendered a single time on page load.



I'm relatively new to React, and hope that I'm not overlooking a simple answer in my ignorance. Any insights into the theory of how to approach and deal with this problem would be much appreciated!










share|improve this question




























    0















    I'm developing a Node JS App using Electron and rendering the UI using React.
    Simply, the user enters print commands in a word-processor component on the left side of the UI, and React interperets those commands and renders the content connected to those commands in real-time on the right side of the UI.
    For example, Render Text "X" at coordinates X1, Y1. Rendering this kind of command is simple to do by triggering a change in state when the user enters a new command, and updating the rendered view of the command with a draw(). However, I am having difficulty deciding the best way to handle a problem senario when (1) the command coordinate given is not absolute but instead is relative to a prior command rendered component, and (2) the relational component does not have a known size that can be determined without rendering it first (usually it contains text with various fonts and font-sizes and varying character content). I'm trying to figure out the best way to implement the draw() calls in a way that will get me an accurately rendered image without unnecessary additional draw commands for both the statically positioned and dynamically positioned components.



    I have thought about inserting the unknown relational components directly into the DOM with javascript, finding the size and saving it for the render, then hiding/removing them, but realize that this is poor practice when using React because obfuscates the true state of the DOM.
    I googled this problem, and found this topic on StackOverflow (Get the height of a Component in React) which discusses using the ref variable as a callback to re-render the UI once the size is known. However, I wasn't sure if this solution was out-dated (this post is 3 years old), or if this was a practical solution for my use case since the rendered view on the right side is constantly changing as the user enters input on the command side of the UI instead of rendered a single time on page load.



    I'm relatively new to React, and hope that I'm not overlooking a simple answer in my ignorance. Any insights into the theory of how to approach and deal with this problem would be much appreciated!










    share|improve this question
























      0












      0








      0








      I'm developing a Node JS App using Electron and rendering the UI using React.
      Simply, the user enters print commands in a word-processor component on the left side of the UI, and React interperets those commands and renders the content connected to those commands in real-time on the right side of the UI.
      For example, Render Text "X" at coordinates X1, Y1. Rendering this kind of command is simple to do by triggering a change in state when the user enters a new command, and updating the rendered view of the command with a draw(). However, I am having difficulty deciding the best way to handle a problem senario when (1) the command coordinate given is not absolute but instead is relative to a prior command rendered component, and (2) the relational component does not have a known size that can be determined without rendering it first (usually it contains text with various fonts and font-sizes and varying character content). I'm trying to figure out the best way to implement the draw() calls in a way that will get me an accurately rendered image without unnecessary additional draw commands for both the statically positioned and dynamically positioned components.



      I have thought about inserting the unknown relational components directly into the DOM with javascript, finding the size and saving it for the render, then hiding/removing them, but realize that this is poor practice when using React because obfuscates the true state of the DOM.
      I googled this problem, and found this topic on StackOverflow (Get the height of a Component in React) which discusses using the ref variable as a callback to re-render the UI once the size is known. However, I wasn't sure if this solution was out-dated (this post is 3 years old), or if this was a practical solution for my use case since the rendered view on the right side is constantly changing as the user enters input on the command side of the UI instead of rendered a single time on page load.



      I'm relatively new to React, and hope that I'm not overlooking a simple answer in my ignorance. Any insights into the theory of how to approach and deal with this problem would be much appreciated!










      share|improve this question














      I'm developing a Node JS App using Electron and rendering the UI using React.
      Simply, the user enters print commands in a word-processor component on the left side of the UI, and React interperets those commands and renders the content connected to those commands in real-time on the right side of the UI.
      For example, Render Text "X" at coordinates X1, Y1. Rendering this kind of command is simple to do by triggering a change in state when the user enters a new command, and updating the rendered view of the command with a draw(). However, I am having difficulty deciding the best way to handle a problem senario when (1) the command coordinate given is not absolute but instead is relative to a prior command rendered component, and (2) the relational component does not have a known size that can be determined without rendering it first (usually it contains text with various fonts and font-sizes and varying character content). I'm trying to figure out the best way to implement the draw() calls in a way that will get me an accurately rendered image without unnecessary additional draw commands for both the statically positioned and dynamically positioned components.



      I have thought about inserting the unknown relational components directly into the DOM with javascript, finding the size and saving it for the render, then hiding/removing them, but realize that this is poor practice when using React because obfuscates the true state of the DOM.
      I googled this problem, and found this topic on StackOverflow (Get the height of a Component in React) which discusses using the ref variable as a callback to re-render the UI once the size is known. However, I wasn't sure if this solution was out-dated (this post is 3 years old), or if this was a practical solution for my use case since the rendered view on the right side is constantly changing as the user enters input on the command side of the UI instead of rendered a single time on page load.



      I'm relatively new to React, and hope that I'm not overlooking a simple answer in my ignorance. Any insights into the theory of how to approach and deal with this problem would be much appreciated!







      html reactjs






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 22 at 18:41









      ChrisChris

      798




      798






















          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55305969%2fpositioning-components-on-render-relative-to-unknown-size-of-other-components%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55305969%2fpositioning-components-on-render-relative-to-unknown-size-of-other-components%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript