React-Google-Apps-Script icon indicating copy to clipboard operation
React-Google-Apps-Script copied to clipboard

Best Practice for Server --> Client via Scriptlets, onSelectionChange

Open semireg opened this issue 1 year ago • 0 comments

If I add a property to a template in ui.js such as:

  const template = HtmlService.createTemplateFromFile('sidebar');
  template.uuid = 'abc123';
  const html = template.evaluate();
  html.setTitle('My Sidebar');
  SpreadsheetApp.getUi().showSidebar(html);

How do I access "uuid" in React via Scriptlets?

I've tried modifying sidebar/index.html

<script>
      window.uuid = JSON.parse(<?= uuid ?>);
      console.log(`window.uuid:${window.uuid}`);
</script>

But I'm not seeing anything. It's probably obvious... 😄

On another note... is there any way to push data from server to client when onSelectionChange is called?

semireg avatar Apr 28 '23 04:04 semireg