GoncharukOrg / react-input

109 stars 9 forks source link

Cannot find module '@react-input/core/hooks/useConnectedInputRef' from 'node_modules/@react-input/mask/dist/node/InputMask.cjs' #2

Closed 79it closed 1 year ago

79it commented 1 year ago

Using version 1.0.11, Jest tests for components with a reference to @react-input/mask are erroring with the following message:

Cannot find module '@react-input/core/hooks/useConnectedInputRef' from 'node_modules/@react-input/mask/dist/node/InputMask.cjs'

Looking at the source of 'node_modules/@react-input/mask/dist/node/InputMask.cjs it has:

"use strict";var e=require("./InputMask.cjs"),r=require("./useMask.cjs");require("react"),require("@react-input/core/hooks/useConnectedInputRef"),require("@react-input/core/errors/SyntheticChangeError"),require("@react-input/core/hooks/useInput"),exports.InputMask=e,exports.useMask=r;

The useConnectedInputRef.js path is actually @react-input/core/dist/hooks/useConnectedInputRef.js

It looks like the require statement is missing /dist

For now I'm going to revert to 1.0.10 which was working really well.

GoncharukBro commented 1 year ago

Please update the @react-input/mask package to version 1.0.12. Although version 1.0.10 has no functional differences, it is better to be able to upgrade to the latest version of the package.

Tested with:

import { render, screen } from '@testing-library/react';
import { InputMask } from '@react-input/mask';

test('render input mask component', () => {
  render(<InputMask placeholder="input" />);
  const InputElement = screen.getByPlaceholderText(/input/i);
  expect(InputElement).toBeInTheDocument();
});

Please provide feedback if possible.

79it commented 1 year ago

Thanks @GoncharukBro, a really speedy reply and fix - awesome!