Skip to content
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

(Inline-Input) component is throwing error when testing with vitest #154

Closed
devconn99 opened this issue Apr 24, 2024 · 3 comments
Closed

Comments

@devconn99
Copy link

I'm submitting a...


[x] Bug report

Current behavior

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object

Expected behavior

To work

Minimal reproduction of the problem with instructions

// React
import React from 'react';
import { useState } from 'react';

// Vitest
import { describe, it } from 'vitest';

// Testing library
import '@testing-library/jest-dom/vitest';
import { render } from '@testing-library/react';

// Reablocks
import { ThemeProvider, theme, InlineInput } from 'reablocks';

const TestComponent = () => {
const [text, setText] = useState('');
return (

<div
style={{
border: 'var(--input-border)',
borderRadius: 'var(--border-radius-md)',
padding: 'var(--spacing-sm)'
}}
>
<InlineInput
value={text}
onChange={event => setText(event.target.value)}
placeholder="Type here..."
/>

;

);
};

describe('Test', () => {
it('Should render', () => {
// Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object
render();
});
});

Environment


Libs:
- react version: 18.2.0
- reablocks version: 7.3.4

Browser:
- [x] Chrome (desktop) version latest
 
For Tooling issues:
- Node version: 20.11.1
- Platform:  Windows 10
@steppy452
Copy link
Contributor

Duplicate issue reported here: #141

I'm looking into this at the moment

@devconn99
Copy link
Author

The problem for "InlineInput" is coming from "react-18-input-autosize" library.
For example when I'm changing AutosizeInput to 'input' in this part of code - "node_modules/reablocks/dist/index.js"

const InlineInput = forwardRef(
  ({
    inputClassName,
    placeholderIsMinWidth = true,
    theme: customTheme,
    ...rest
  }, ref) => {
  const theme2 = useComponentTheme("input", customTheme);
  return jsx(
    AutosizeInput,
    {
       inputRef: ref,
       inputClassName: twMerge(theme2.inline, inputClassName),
       placeholderIsMinWidth,
       ...rest
    });
  }
);

The test is passing, but the input is becoming non-resizable.
Also it's fixing the problem with Select component. Idk how they are related, but it's being fixed too

@devconn99
Copy link
Author

@steppy452
I opened PR for this issue.
can you please review?

@amcdnl amcdnl closed this as completed May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants