/**
 * Copyright (c) 2025 Huawei Technologies Co., Ltd.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

import React from 'react';
import {useState} from 'react';

export function StateKeeper<T>(props: {
  initialValue: T;
  renderContent: (
    value: T | undefined,
    setValue: React.Dispatch<React.SetStateAction<T>>,
  ) => any;
}) {
  const [value, setValue] = useState<T>(props.initialValue);

  return <>{props.renderContent(value, setValue)}</>;
}