import { invariant } from "../../invariant";
import usePreviousRef from "../use-previous-ref";
import useDevSetupWarning from "../use-dev-setup-warning";
import useDev from "../use-dev";

export default function useValidateSensorHooks(sensorHooks) {
  useDev(() => {
    const previousRef = usePreviousRef(sensorHooks);
    useDevSetupWarning(() => {
      invariant(
        previousRef.current.length === sensorHooks.length,
        "Cannot change the amount of sensor hooks after mounting"
      );
    });
  });
}
