replugged

    Function useSetting

    • React hook for managing settings.

      Type Parameters

      • Settings extends Record<string, Jsonifiable>
      • Defaults extends string | number | symbol
      • PathKey extends string
      • Fallback extends undefined | {} | Jsonifiable
      • Path extends string
      • Value

      Parameters

      Returns {
          onChange: (
              newValue:
                  | ChangeEvent<HTMLInputElement>
                  | ValueAtPath<Settings, Path>
                  | Settings[PathKey]
                  | Record<string, unknown> & {
                      checked?: ValueAtPath<Settings, Path>;
                      value?: ValueAtPath<Settings, Path>;
                  }
                  | Record<string, unknown> & {
                      checked?: Settings[PathKey];
                      value?: Settings[PathKey];
                  },
          ) => void;
          value: Value;
      }

      A tuple containing the current value of the setting, and a function to set the value. Works like useState.

      import { components, settings } from "replugged";
      const { TextInput } = components;

      const cfg = settings.init<{ hello: string }>("dev.replugged.Example");

      export function Settings() {
      return <TextInput {...cfg.useSetting("hello", "world")} />;
      }
    MMNEPVFCICPMFPCPTTAAATR