initState
As we have seen in the Callback section, the Callback
object has a property called requestState
. This property can be used to initialize the CalcGatewayForm
with previous values. This is useful when you want to restore the form state after a page refresh.
To render the form with the previous values, you can pass the requestState
object to the initState
prop of the CalcGatewayForm
component.
If the initState
object is null or undefined, the component will be initialized with the default values provided by the UIControls.
Usage
import {CalcGatewayForm} from 'kampmann-calcgateway-frontend'
function App() {
const [result, setResult] = useState({})
// the callback.requestState can be used to initialize the CalcGatewayForm with previous values
// the value is passed to the callback function of the CalcGatewayForm component as the "requestState" property
const oldRequestState = oldResult.requestState
return (
<CalcGatewayForm
...
Callback={setResult}
initState={oldRequestState}
/>
)
}