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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@garpix/fetcher

v3.0.0

Published

garpix fetcher

Downloads

7

Readme

Как использовать Fetcher

Импортируем

import { Fetcher } from '@garpix/fetcher';

В компонент который является странице необходимо добавить Fetcher и прокинуть все props из react-router-dom.

paramsKey отвечает за ключ в объекте match.params на который будет происходить обновление.

<Fetcher {...props} paramsKey={'0'}>
  {(data, error) => {
    if(data === null && error !== null) return <ErrorPage error={error} />
    if(!data) return null;
    const { pageType, page } = data;
    const Page = PAGE_TYPES[pageType];
    return <Page {...page} />
  }}
</Fetcher>

Следуя документации настраиваем https://github.com/storeon/storeon

И добавляем

import { page } from '@garpix/fetcher';
const storeonParams = [
    ...
    page,
]

FetcherList

Параметры компонента

api: эндпоинт куда фечер будет бегать за данными

  • пример эндпоинта
import BaseApi from '@garpix/base-api';

export default class ContentApi extends BaseApi {
  getCatalogData = async (params = {}) => {
    const res = await this.get('/catalog/product/', params);
    return res.data;
  };
}

Пример использования

<FetcherList api={contentApi.getCatalogData}>
  {(data) => {
    const {
      count,
      results = [],
      activePage,
      loadData,
      showMore,
      status,
      filterParams,
      deleteElement,
      updateElement,
      deleteElementByKey,
      updateElementByKey,
      isNext,
      isPrev,
    } = data;
    return (
      <>
        <AppliedFilters />
        <FiltersCatalog
          categories={categories}
          brands={brands}
          multy_choise_filters={multy_choise_filters}
        />
        <ProductGrid results={results} />
      </>
    );
  }}
</FetcherList>

Параметры функции рендера

count: общее колличество элементов

results: множество данных описывающих основные сущности

activePage: текущяя активная страница пагинации

loadData: функция принимающяя (page, filterParams, isConcat) Название параметра | Параметры ----------------|---------------------- page | обязательный параметр filterParams | {} isConcat | false

  • применима в момент когда необходимо обновить results с применением некоторых фильтров

showMore: функция которая может подгрузить еще данных в results

status: текущий статус получения данных loading, failed, loaded

filterParams: текущие примененные фильтры

deleteElement: функция которая удаляет элемент по его индексу

  • в качестве параметра принимает index

deleteElementByKey: функция которая удаляет элемент по его ключу

  • в качестве параметра принимает value, key

updateElementByKey: функция которая обновляет элемент по его ключу

  • в качестве параметра принимает obj , value, key

isNext: этот параметр говорит о том есть ли следующяя страница bollean

isPrev: этот параметр говорит о том есть ли предыдущая страница bollean

otherData: этот параметр содержит дополнительные данные с АПИ. По умолчанию undefined

reload: Запрашивает данные с текущими фильтрами

Changelog

See CHANGELOG.md.

Contributing

See CONTRIBUTING.md.

License

MIT