javascript - ReactJS manipulate existing DOM element -


i got task during job interview. i'm new reactjs couldn't find proper solution.

i'm supposed make bootstrap's toggle box: image example

the important thing here component should invoked way:

<togglebox header="the title goes here">    content of toggle box </togglebox> 

i'm not sure think mean invoking html code attached dom , not using react.render().

however, far know, reactjs isn't structured rebuilding existing dom, there workaround accomplish task? maybe got wrong , "invoking" mean use react.render()?

thanks! :-)

the component need use this.props.children. can @ documentation here.

here's example:

var withchildren = react.createclass({     render: function() {         var child = this.props.children;         var header = this.props.header;         return (             <div>                 <div>{header}</div>                 <div>{child}</div>             </div>         );     } });  react.render(<withchildren header="title goes here">some content</withchildren>, document.queryselector('.app')); 

if run see some content rendered. need markup , css make image.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -