@jcartledge/react-conditional
TypeScript icon, indicating that this package has built-in type declarations

1.0.9 • Public • Published

React conditional

CI

Simple utility component for React that only renders its children when the boolean predicate prop is true.

describe("Conditional", () => {
  it("renders children if the predicate is true", () => {
    render(
      <Conditional predicate={true}>
        some children
      </Conditional>
    );

    expect(
      screen.queryByText(/some children/)
    ).toBeInTheDocument();
  });

  it("does not render children if the predicate is false", () => {
    render(
      <Conditional predicate={false}>
        some children
      </Conditional>
    );

    expect(
      screen.queryByText(/some children/)
    ).not.toBeInTheDocument();
  });
});

Readme

Keywords

none

Package Sidebar

Install

npm i @jcartledge/react-conditional

Weekly Downloads

40

Version

1.0.9

License

ISC

Unpacked Size

6.36 kB

Total Files

12

Last publish

Collaborators

  • jcartledge