Skip to content

Commit c45d5c5

Browse files
committed
amended input component ref implementation to incorporate MutableRefObject
1 parent 7f0a63a commit c45d5c5

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

src/components/input/Input.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import React, { HTMLProps } from 'react';
1+
import React, { HTMLProps, MutableRefObject } from 'react';
22
import classNames from 'classnames';
33
import FormGroup from '../../util/FormGroup';
44
import { InputWidth } from '../../util/types/NHSUKTypes';
55
import { FormElementProps } from '../../util/types/FormTypes';
66

77
interface InputProps extends HTMLProps<HTMLInputElement>, FormElementProps {
8-
inputRef?: (inputRef: HTMLInputElement | null) => any;
8+
inputRef?: MutableRefObject<HTMLInputElement | null>;
99
width?: InputWidth;
1010
disableErrorLine?: boolean;
1111
}

src/components/input/__tests__/input.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ describe('Input', () => {
1919
it('should do nothing if ref does not exist', () => {
2020
const useRefSpy = jest.spyOn(React, 'useRef').mockReturnValueOnce({ current: null });
2121
const component = shallow(<InputComp />);
22-
console.log(component.debug());
2322
component.find('Input').simulate('click');
2423
expect(useRefSpy).toBeCalledWith(null);
2524
});
@@ -32,4 +31,4 @@ describe('Input', () => {
3231
expect(useRefSpy).toBeCalledWith(null);
3332
expect(mock).toBeCalledTimes(1);
3433
});
35-
})
34+
})

src/components/select/__tests__/Select.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ describe(`Select`, () => {
2020
it(`should do nothing if ref does not exist`, () => {
2121
const useRefSpy = jest.spyOn(React, 'useRef').mockReturnValueOnce({ current: null });
2222
const component = shallow(<SelectComp />);
23-
console.log(component.debug());
2423
component.find('Select').simulate('click');
2524
expect(useRefSpy).toBeCalledWith(null);
2625
});
27-
})
26+
})

0 commit comments

Comments
 (0)