I have a react component, which has properties and state. Some fields of state contain input data (uplifted from input control), but there is also fields in the state that must
If you are using React 16.8.0 and above, you can use React hooks API. I think it's useMemo() hook you might need. For example:
import React, { useMemo } from 'react'
const MyComponent = ({ ...props }) => {
const calculatedValue = useMemo(
() => {
// Do expensive calculation and return.
},
[a, b]
)
return (
{ calculatedValue }
)
}
For more details, refer to the React documentation