in this render function , I retrieve the data from list in sharepoint and render the fileContent but the properties didn’t replaced from listItems
this is my code of render function that I tried :
public render(): React.ReactElement {
return (
<div className={styles.linkItemsWithReact}>
<ol>
{this.state.listitems.map((listitem, listitemkey) => {
console.log(this.state.listitems);
return (
<li key={listitemkey}>
<a>{this.state.fileContent}</a>
</li>
);
})}
</ol>
</div>
);
}
and I want to render the fileContent of a specific template and displayed the properties of this template from the actual data of listItems
2
Answers
It looks like you are iterating over the
this.state.listitems
yet not using them except as the key prop.Did you mean to render
listitem.fileContent
or similar in the loop?If you can provide more details for the whole state it would be easier to debug your question.
You are not using the value provided by the map callback but instead some other state.
The following code should work if you replace
content
inlistitem.content
with the correct attribute.Also the second parameter of the callback of Array.prototype.map() is the
index
in the array so I changed that as well.