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 🙏

© 2024 – Pkg Stats / Ryan Hefner

spitha

v1.2.7

Published

A Quick React Component that makes React Components Quicker

Downloads

8

Readme

Contributors Forks Stargazers Issues MIT License LinkedIn

About Spitha

Spitha is React Component natively built in Typescript that does most of its work on the backend. It boosts rendering time of components by over 40% with improved Batching, Memoization, and Latency Update Technqiues. The component renders native data within 0.15 miliseconds and components within 0.12 miliseconds compared to the average React Component rendering times of 0.3 miliseconds. This is especially significant for applications that query and render API data and extensive visuals like graph networks.

For rendering native data, Spitha works exactly like any React Component. It can accept props, API calls, and etc, but with improved efficiency!

Similarly, for rendering components (i.e., Chakra Styling), just wrap it around a Spitha Component, and your React App will be optimized - it's that simple!

Spitha is available for both native React Frameworks as well as Frameworks using Typescript to allow all types of applications to be optimized.

Efficient Rendering Count

Spitha has improved State Management where it can verify if API data is already fetched or not. It fetches once per render unless stated other wise the fetchData prop. This in-turn means that while the user may call the API fetch function multiple times on React, Spitha will run it only once. However, to ensure the data rendered is up-to-date, Spitha runs an Asynchronous Loading protocol that calls APIs when the user is not looking at the component (i.e., scrolled down is not indirectly looking at the component).

There has also been an improved Memoization technique employed in Spitha. It ensures the same callback instance is reused across renders and prevents unnecessary re-creation of the function.

Spitha can also be customizable in how it can accept rendering. There is a trigger prop which represents a threshold. This threshold represents the distance the user has to be away from the component for it re-render. Such an Example can be viewed in the Examples Section.

Note: Performance and method of testing can be found in the \testing directory or here:

Getting Started

To start using Spitha, follow these 3 steps.

Prerequisites

Setup your React Framework.

npx create-next-app IloveSpitha --typescript

Installation

After you have setup your project, make sure you have installed the spitha library.

  1. Go to your React Configuration file and ensure you have webpack installed. If you're having errors with typescript, I recommend looking at this Stack Overflow Post for guidance.
    // next.config.mjs
    /** @type {import('next').NextConfig} */
         const nextConfig = {
         reactStrictMode: true,
         transpilePackages: ['spitha'] //Ensuring Webpack can convert TS package into JS
         };
    
         export default nextConfig;
  2. Install the Spitha Package
    yarn install spitha
  3. Import Spitha to your Component file
    //index.tsx 
    //....other modules
    import Spitha from 'spitha'

type MyComponentProps = { fetchData: () => Promise; initialData?: any[]; threshold?: number; children?: React.ReactNode; style?: React.CSSProperties; }

Usage

Spitha does come with a few props to customize the rendering performance. By default, it is set to maximize the performance, but the user may choose to send in props, apply css-styling, etc.

| Spitha Props | Value | | ------------ | ----- | | fetchData | Callback Function: Promise<any> | | initialData? | any[] (optional) | | threshold? | number (optional) | | children? | React Object: React.ReactNode (optional) | | style? | React Object: React.CSSProperties (optional) |

Found below a few examples on how to use Spitha. Do note that these are basic implementations, and Spitha may work for most React applications.

Basic Data Implementation

    <div>
        <WelcomeComponent> Welcome to Spitha!</WelcomeComponent>
        <Text>React just got Faster!!!</Text>
        <h1>{`Test Component ${i + 1}`}</h1>
        <a href={`https://example.com/${i + 1}`}>Visit Test Component made with{i + 1}</a>
        <img src="image.jpg" alt="Image" />;
    </div> 

ChakraUI Component Rendering with Spitha

    import { Text } from "@chakra-ui/react";
    import { Spitha } from "spitha";

    export default function Home() {
    return (
        <div>
        <Spitha fetchData={() => Promise.resolve()}>
            <div>
            <Text fontSize='6xl'>React just got faster!!!</Text>
            <Text>Yayyyyyyyyyy</Text>
            </div>
        </Spitha>
        </div>
    );
    }

Changing Threshold

    <Spitha fetchData={() => Promise.resolve(['initialData'])} threshold={0.4} style={{ color: `#${i}${i}${i}` }}>
      <h1>{`Test Component ${i + 1}`}</h1>
      <a href={`https://example.com/${i + 1}`}>Visit Test Component {i + 1}</a>
      <img src="image.jpg" alt="Image" />;
    </Spitha>

Here, the threshold property is set to 0.4 which means Spitha will re-render when the user is 40% away from the component. Note that there has also a prop sent in the form of a promise initialData as a string.

License

Distributed under the MIT License. See LICENSE.txt for more information.

Contact

Jaival Patel | Spitha | Spitha Docs