clearmatics / qreacto

Run standalone React components in your Quarto project!
https://clearmatics.github.io/qreacto/example.html
MIT License
34 stars 1 forks source link

How to add dynamical content by Props? #20

Closed math4mad closed 10 months ago

math4mad commented 10 months ago

How to add dynamical content by Props?

dweng0 commented 10 months ago

Do you have any more information?

If you mean the initial shortcode on the md file {{< react MyComponent >}}

There is no way to do that as it's your entry component. You could access environment variables, or fetch the required data once inside the component.

However if you're asking about prop drilling: Passing props down to sub components is the same as in any react application:

import RandomWordsComponent from "./RandomWordsComponent";

function MyNestedComponent() {
    return (
      <div>
        <RandomWordsComponent someProp={true}/>
      </div>
    );
  }

export default MyNestedComponent

Then you can access it as you would normally