Skip to content

Mark some parameters as readonly #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/lib/AutoNumericComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ export default function AutoNumericComponent({
autoNumericOptions,
state,
}: {
element: string;
refKey: string;
props?: Parameters<typeof createElement>[1];
autoNumericOptions?: CallbackOptions;
state?: NonNullable<Parameters<typeof AutoNumeric.set>[1]>;
element: Readonly<string>;
refKey: Readonly<string>;
props?: Readonly<Parameters<typeof createElement>[1]>;
autoNumericOptions?: Readonly<CallbackOptions>;
state?: Readonly<NonNullable<Parameters<typeof AutoNumeric.set>[1]>>;
}): JSX.Element {
const htmlElement = useRef<HTMLElement>(null);
const autoNumeric = useRef<AutoNumeric | null>(null);
Expand Down Expand Up @@ -78,7 +78,7 @@ export default function AutoNumericComponent({
htmlElement.current,
autoNumericOptions ?? {},
);
}, [htmlElement.current, autoNumericOptions]);
}, [htmlElement.current]);

if (state !== undefined) {
useEffect(() => {
Expand Down
9 changes: 5 additions & 4 deletions src/lib/AutoNumericInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export type InputProps = Omit<
* JSX!IntrinsicElements.input.props}.
* @param options.autoNumericOptions - Options passed to {@link !AutoNumeric}. Same as {@link
* AutoNumeric!Options}.
* @param options.valueState - The state and state setter from the parent component.
* @param options.valueState - The state and state setter from the parent component to be passed
* into this component.
* @param options.valueState.state - The state from the parent component to be passed in.
* @param options.valueState.stateSetter - The callback function that sets
* `options.valueState.state`.
Expand All @@ -44,10 +45,10 @@ export function AutoNumericInput({
autoNumericOptions,
valueState,
}: {
inputProps?: InputProps;
autoNumericOptions?: CallbackOptions;
inputProps?: Readonly<InputProps>;
autoNumericOptions?: Readonly<CallbackOptions>;
valueState?: {
state: string;
state: Readonly<string>;
stateSetter: React.Dispatch<React.SetStateAction<string>>;
};
}): JSX.Element {
Expand Down