Let's say I have a simple reaction component:
import React from 'react'; import styles from "./index.css"; export default React.createClass({ render: function() { return ( <header className={styles.root}> // area for child content {this.props.children} </header> ); } });
Now let's say that instead of one area for any child components, I would like two, for example:
import React from 'react'; import styles from "./index.css"; export default React.createClass({ render: function() { return ( <header className={styles.root}> <div className={styles.logo}> // logo children here </div> <div> // navigation children here </div> </header> ); } });
I know that I could use attributes, but that would not be very elegant for a large piece of html content. How can this be done in a reaction in such a way as, for example, the named blocks in swig?
An example of named blocks:
{% extends 'layout.html' %} {% block title %}My Page{% endblock %} {% block head %} {% parent %} <link rel="stylesheet" href="custom.css"> {% endblock %} {% block content %} <p>This is just an awesome page.</p> {% endblock %}
You see that these blocks can be used by referring to their name, and thus allow the "display" of several areas of content. I hope there is an equally elegant way to respond to this, as it makes components very complex.
anon
source share