Answer the question
In order to leave comments, you need to log in
React how to limit output?
There is a function in the react component that displays an object:
The essence of the problem is how to make restrictions on the output, that is, display only 1 object if y is kind. component passed parameter limit? and if not, display all
renderGenry(){
const genriesJson = this.props.genries;
return(
Object.keys(genriesJson).map((id, index) => (
<NavLink key={index + 'link'} to="/">
{genriesJson[id]}
</NavLink>
))
)
}
Answer the question
In order to leave comments, you need to log in
Object.keys(genriesJson) is an array, and arrays can be limited using a slice through slice
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question