D
D
Danil Gaisin2020-07-24 17:12:19
React
Danil Gaisin, 2020-07-24 17:12:19

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

spoiler

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

1 answer(s)
V
Vladimir Proskurin, 2020-07-24
@gaisindanil

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 question

Ask a Question

731 491 924 answers to any question