npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

tchisama-react-logic

v1.0.6

Published

nothing here

Downloads

46

Readme

Certainly! Here's the updated README with code results added to each component:

tchisama-react-logic

Overview

tchisama-react-logic is a library of non-UI components designed to enhance the React coding experience by providing useful utilities for handling conditional rendering, looping through data, working with dates, and more. This README provides an overview of the available components and how to use them.

Installation

You can install tchisama-react-logic via npm or yarn:

npm install tchisama-react-logic
# or
yarn add tchisama-react-logic

Components

1. Switch, Case, Default

The Switch component allows you to conditionally render content based on the provided value. Use Case components to define different cases and a Default component for a fallback.

| Prop | Description | Example | |------------------|--------------------------------------------------|---------------------------------------------------| | value | The value to evaluate against cases. | "case2" |

<Switch value="case2">
  <Case value="case1">Render content for case 1</Case>
  <Case value="case2">Render content for case 2</Case>
  <Case value="case3">Render content for case 3</Case>
  <Default>Render something else</Default>
</Switch>

Result:

Render content for case 2

2. Loop

The Loop component simplifies iterating through an array of items and rendering them. It supports pagination, click handling, and an empty message.

| Prop | Description | Example | |------------------|--------------------------------------------------|---------------------------------------------------| | className | CSS classes for the container element. | '' | | items | An array of items to iterate through. | data (an array of items) | | renderItem | A function to render each item. | (item) => <div>{item.name}</div> | | onItemClick | A function to handle item click events. | (item) => { /* Handle item click here */ } | | emptyMessage | Message to display when no items are found. | "No items found" | | keyProp | The property to use as the unique key for items. | "id" | | pageSize | Number of items to display per page. | 3 | | pagination | Enable or disable pagination. | true |

<Loop
  className=''
  items={data}
  renderItem={(item) => <div>{item.name}</div>}
  onItemClick={(item) => {
    // Handle item click here
    console.log(`Item clicked: ${item.name}`);
  }}
  emptyMessage="No items found"
  keyProp='id'
  pageSize={3}
  pagination
/>

Result:

// Rendered list of items with pagination, click handling, and empty message

3. DateComponent

The DateComponent component allows you to format and display dates easily.

| Prop | Description | Example | |------------------|--------------------------------------------------|---------------------------------------------------| | className | CSS classes for the container element. | 'bg-blue-600 w-fit p-2 rounded-md' | | value | The date object to format and display. | new Date() | | get | The part of the date to display (e.g., 'date'). | "date" |

<DateComponent
  className='bg-blue-600 w-fit p-2 rounded-md' 
  value={new Date()} 
  get="date" 
/>

Result:

// Rendered formatted date

4. If, True, False

The If component enables conditional rendering based on a given condition. Use True and False components to specify what to render in each case.

| Prop | Description | Example | |------------------|--------------------------------------------------|---------------------------------------------------| | con | The condition to evaluate. | 1 > 2 |

<If con={1 > 2}>
  <True>if true</True>
  <False>if false</False>
</If>

Result:

if false

5. Random, RandomItem

The Random component randomly selects and renders one of its children.

<Random>
  <RandomItem>a</RandomItem>
  <RandomItem>b</RandomItem>
  <RandomItem>c</RandomItem>
</Random>

Result:

// Rendered random child (e.g., 'a', 'b', or 'c')

Usage

  1. Install tchisama-react-logic using npm or yarn as shown in the Installation section.
  2. Import the components you need in your React components:
import { Switch, Case, Default, Loop, DateComponent, If, True, False, Random, RandomItem } from 'tchisama-react-logic';
  1. Use the imported components in your JSX as demonstrated in the component descriptions above.

License

This package is open-source and available under the MIT License.


Now the README includes code results for each component to provide a clearer understanding of how they work.