When working on a project, I ran into a problem. In general, I get JSON data on the API and display the data in a table. In the table there are fields that can be changed (numeric).
It is necessary to make sure that after input to the input data, the information is sent to the Server by API. Everything is processed there, some data is counted, and then I need to retrieve all the data from the server again.
Of course, there is an onChange option for input, but I don’t want to send a request to the server every time you enter a single character and receive a lot of data again, this slows down the work (people entered 5 characters - 5 requests and 5 responses with fairly large data).
An example of my component:
class Table extends React.Component { handleOnChange(){ ... } render() { const data = this.props.data; return ( <table> ... <tbody> {data.map(item => ( <tr> <td>{item.id}</td> <td> <input type="text" placeholder={item.count} onChange={() => this.handleOnChange()} /> </td> </tr> )} </tbody> </table> ) } } How to make an idea? I tried to make a new component and process events there and send data by setTimeout, but I didn’t understand how to call a function from TableTr , for example, which is a Table and pass arguments to it (value input). Ref-s will not work like, there will be many TableTr components.