D
D
DyadkoOrest2021-05-06 17:49:35
React
DyadkoOrest, 2021-05-06 17:49:35

How to artificially limit the number of renders per second?

I have a component that receives data from the server, and due to the fact that the data changes very quickly, the component is rendered about 30 times per second.
Everything is as it should be, only in one component I need to limit the number of renders. Perhaps there is some way to manually set the component to render for example once a second.
This is a normal functional component that receives data as props.

import React from 'react'

function Component({ data }) {
  return (
    //here code
  )
}

export default Component

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikhail Osher, 2021-05-06
@miraage

Let the parent component control that this prop changes every N seconds + wrap the child component in React.memo

A
Alice, 2021-05-06
@w3bsmes

Hold and hold

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question