Skip to content

Using react components #1095

Answered by c6p
c6p asked this question in Q&A
Mar 18, 2024 · 1 comments · 4 replies
Discussion options

You must be logged in to vote

Updated.

Define root div to mount our component. Note: selected is reactive. Yay!

<link rel="stylesheet" href="npm:@mantine/core/styles.css" />
<div id="root"></div>

Selected values: ${selected.join(', ')}

I've found out easiest way to manage state via Mutable. Here we define a reusable useState hook as in react.

import {Mutable} from "npm:@observablehq/stdlib";
function useState(value) {
  const state = Mutable(value)
  const setState = (value) => state.value = value;
  return [state, setState]

}
const [selected, setSelected] = useState(["react"])

I misunderstood how observable renders the page. It was enough to just import them as you would in node.
Since JSX is not supported, use cre…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@Fil
Comment options

Fil Mar 19, 2024
Collaborator

@c6p
Comment options

@Fil
Comment options

Fil Mar 20, 2024
Collaborator

@c6p
Comment options

Answer selected by c6p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants