Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ForwardRef, isMemo } from 'react-is';
import useMemo from './hooks/useMemo';
import isFragment from './React/isFragment';

const ReactMajorVersion = Number(version.split('.')[0]);
const ReactMajorVersion = Number(version?.split('.')[0]);

export const fillRef = <T>(ref: React.Ref<T>, node: T) => {
if (typeof ref === 'function') {
Expand Down
10 changes: 10 additions & 0 deletions tests/ref-version.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
jest.mock('react', () => ({
...jest.requireActual('react'),
version: undefined,
}));

describe('ref without a React version export', () => {
it('loads without throwing', () => {
expect(() => jest.requireActual('../src/ref')).not.toThrow();
});
});