Skip to content

Commit 3b12cc3

Browse files
authored
Mark some parameters as readonly (#10)
1 parent 353f5ce commit 3b12cc3

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/lib/AutoNumericComponent.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ export default function AutoNumericComponent({
4646
autoNumericOptions,
4747
state,
4848
}: {
49-
element: string;
50-
refKey: string;
51-
props?: Parameters<typeof createElement>[1];
52-
autoNumericOptions?: CallbackOptions;
53-
state?: NonNullable<Parameters<typeof AutoNumeric.set>[1]>;
49+
element: Readonly<string>;
50+
refKey: Readonly<string>;
51+
props?: Readonly<Parameters<typeof createElement>[1]>;
52+
autoNumericOptions?: Readonly<CallbackOptions>;
53+
state?: Readonly<NonNullable<Parameters<typeof AutoNumeric.set>[1]>>;
5454
}): JSX.Element {
5555
const htmlElement = useRef<HTMLElement>(null);
5656
const autoNumeric = useRef<AutoNumeric | null>(null);
@@ -78,7 +78,7 @@ export default function AutoNumericComponent({
7878
htmlElement.current,
7979
autoNumericOptions ?? {},
8080
);
81-
}, [htmlElement.current, autoNumericOptions]);
81+
}, [htmlElement.current]);
8282

8383
if (state !== undefined) {
8484
useEffect(() => {

src/lib/AutoNumericInput.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ export type InputProps = Omit<
3333
* JSX!IntrinsicElements.input.props}.
3434
* @param options.autoNumericOptions - Options passed to {@link !AutoNumeric}. Same as {@link
3535
* AutoNumeric!Options}.
36-
* @param options.valueState - The state and state setter from the parent component.
36+
* @param options.valueState - The state and state setter from the parent component to be passed
37+
* into this component.
3738
* @param options.valueState.state - The state from the parent component to be passed in.
3839
* @param options.valueState.stateSetter - The callback function that sets
3940
* `options.valueState.state`.
@@ -44,10 +45,10 @@ export function AutoNumericInput({
4445
autoNumericOptions,
4546
valueState,
4647
}: {
47-
inputProps?: InputProps;
48-
autoNumericOptions?: CallbackOptions;
48+
inputProps?: Readonly<InputProps>;
49+
autoNumericOptions?: Readonly<CallbackOptions>;
4950
valueState?: {
50-
state: string;
51+
state: Readonly<string>;
5152
stateSetter: React.Dispatch<React.SetStateAction<string>>;
5253
};
5354
}): JSX.Element {

0 commit comments

Comments
 (0)