I have encountered some example JSX code in a book which took me by surprise - it contains an anchor tag in the single (non-closed) form. I have simplified the code:
function CustomAnchor(props) {
return <a {...props}/>;
};
ReactDOM.render(
<CustomAnchor href="http://reactjs.com">A link</CustomAnchor>,
document.getElementById('container')
);
The code works, but I haven't been able to find any documentation that describes this way of describing the anchor tag in JSX. I expected to have to use an opening & closing A tag, enclosing props.children - i.e - something like this:
return <a {...props}>{props.children}</a>
The latter form is in fact how it was done a bit earlier in this same book, and no explanation has been given on the new more condensed form. FWIW, the book is "React Up & Running", by Stoyan Stefanov. I'd appreciate some help here before I consider submitting a suggestion to add an explanation to the book.