Answers for "html pass attribute to react"

0

html pass attribute to react

<div id="container" data-title="Hello" data-name="World">
    <!-- This element's contents will be replaced with your component. -->
</div>

--------------------------------------------------------------------------

var Hello = props => (
    <div>{ props.title}, { props.name }</div>
);

var root = document.getElementById('container');

ReactDOM.render(
  <Hello {...(root.dataset)} />,
  root
);
Posted by: Guest on August-14-2021

Browse Popular Code Answers by Language