Skip to content

refs are not resolved #55

@manast

Description

@manast

I apologize if this issue is known, or if it does not belong to this repo, but I could not find any answer anywhere, including ChatGPT.

Consider this dummy component:

import { Component, onMount } from "solid-js";

const Button: Component<void> = () => {
  let myButton: HTMLButtonElement;

  onMount(() => {
    console.log({ myButton });
  });

  return <button ref={myButton!}>Text</button>;
};

export default Button;

When running this component, the button element will be printed on the console, however when running the following test the ref is undefined

import { describe, it } from "vitest";
import { render } from "@solidjs/testing-library";
import Button from "./button";

describe("Button Component", () => {
  it("renders correctly", async () => {
    render(() => <Button />);
  });
});

Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions