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.

How to append dynamic value? like ``jsx`${value_from_var}```

See original GitHub issue

Last night I wrote

let jsx = htm.bind(h);
let data = '<p>test</p>
let Test =()=> jsx`${data}`
render(Test(), document.querySelector('#content'));

But it just render plain text instead p element. How to solve that? Anyway I’m using ES Module right in the browser without NodeJS nor Bundle system.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
oolingcommented, Nov 20, 2022

It worked, noice!

2reactions
rschristiancommented, Nov 20, 2022

it looks mesy :

That looks to be a rendering error in your browser, quite frankly. I’d use something else. It’s like elements are duplicated out of place and without styling. Really odd.

can you just share the code here?

import { html, render, useState } from 'https://cdn.skypack.dev/htm/preact/standalone';

const data = '<h1 style="color: white">Hello World!</h1>';

function App() {
    const [score, setScore] = useState(0);
    const Button = () => html`<button onClick=${() => setScore(score + 1)}>${score}</button>`;
    
    return html`
      ${html([data])}
      <${Button} />
    `;
}

render(html`<${App} />`, document.body);
Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Append a value dynamically to js variable name
I want to add a dynamic value to a variable name. Instance: I got a value 24 from webpage. now i want to...
Read more >
Dynamic appending of values containing specific strings
What I would like is to append the following information into an array variable with the following three variables listed down below. Since ......
Read more >
APPENDING A DYNAMIC VALUE ON A TABLE IN INSERT ...
You need to use dynamic sql. Something like this: SET v_sql_stmt = 'INSERT INTO LOG_Table'|| 'PRODUCT_NAME' ||' SELECT 1,''Success'';'.
Read more >
How To Add Dynamic Variable To A List - Studio - UiPath Forum
Hi, I'm running into a problem where I have a dynamic variable that changes through each iteration not being added to a list....
Read more >
Predefined and dynamic key-values - Google Ad Manager Help
When you add key-values, you'll need to understand the difference between ... Use dynamic targeting if you don't want to define key values...
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