Answer the question
In order to leave comments, you need to log in
Why isn't the set of React components rendered?
Why isn't the set of React components rendered? - I can't catch the error. The following thing doesn't output anything, even though it should:
return document.getElementsByTagName("main")[0].getElementsByTagName("section").map(theArrayElement => <p>Paragraph!</p>);
return document.getElementsByTagName("main")[0].getElementsByTagName("section").length;
return document.getElementsByTagName("main")[0].getElementsByTagName("section")[0].innerText;
return [0, 0, 0].map(theArrayElement => <p>Paragraph!</p>);
class ContentsList extends React.Component {
render() {
// Тот самый return - и больше ничего
}
}
Answer the question
In order to leave comments, you need to log in
I don't know what you are trying to do and I understand that the reason is that the getElementsByTagName method returns not an array, but an HTMLCollection , which does not have the map method you are trying to use.
You can solve the problem by casting the result to an array:
Array.from(document.getElementsByTagName("main")[0].getElementsByTagName("section")).map(theArrayElement => <p>Paragraph!</p>);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question