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

@kwikpik/kwikpik-react

v1.0.7

Published

<p align="center"><img src="https://drive.google.com/uc?id=1RKi_LSKqBJfFQWKt_A8TC8BSono2dLhx&export=view" width="50%" height="200" alt="kwikpik" /></p>

Downloads

5

Readme

kwikpik-react

npm npm npm

Introduction

kwikpik-react is a simple and convenient React library that provides an interface through which users can interact with the Kwik Pik's gateway. If you aim to provide logistic services to users without hassle, then this library is for you React lovers.

Table of Content

  1. Installation
  2. Overview & Usage

Installation

The package can be installed using traditional package managers like npm and yarn like so:

npm install --save @kwikpik/kwikpik-react

or

yarn add @kwikpik/kwikpik-react

Overview & Usage

kwikpik-react can only be used in an app that uses the React library. It provides a custom button, a context provider and a dispatch view.

KwikPikContextProvider

The context provider makes it convenient to provide the global/app-wide configuration necessary to interact with the Kwik Pik gateway from a client-side. The configuration can be loaded using any of useKwikPikContext or useContextDispatchView. The first allows to just load the values from the provided configuration whereas the second returns an already configured DispatchView.

The following props are passed to the KwikPikContextProvider component:

| Prop | Type | Description | | ----------- | ----------------------------------- | --------------------------------------------------------------------------------------------- | | apiKey | string | Your API key gotten from the business dashboard | | mapsApiKey | string | Your Google Maps API key. This is necessary for the autocomplete & geocoding features to work | | environment | "dev"| "prod" | undefined | The environment to use. dev (Development) or prod (Production). Defaults to "prod". |

Example

import React from "react";
import ReactDOM from "react-dom/client";
import "./index.css";
import App from "./App";
import { KwikPikContextProvider } from "@kwikpik/kwikpik-react";
import reportWebVitals from "./reportWebVitals";

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
  <React.StrictMode>
    <KwikPikContextProvider apiKey="YOUR_API_KEY" environment="dev" mapsApiKey="YOUR_GOOGLE_API_KEY">
      <App />
    </KwikPikContextProvider>
  </React.StrictMode>
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();

The useKwikPikContext function can be used to retrieve the values of these props like so

// Removed for brevity
const { apiKey, mapsApiKey, environment } = useKwikPikContext();

You can use the useContextDispatchView function to create a configured DispatchView. The following optional props can be passed to the created component

| Prop | Type | Description | | ------- | -------- | ------------------------------------------------------------------ | | visible | boolean | Whether the dispatch modal is visible or not | | onClose | function | Function that gets executed when the "x" labeled button is clicked |

import "./App.css";
import { useState } from "react";
import { useKwikPikContextDispatchView, useStandaloneDispatchView } from "@kwikpik/kwikpik-react";

function App() {
  const [showContextLoadedView, setShowLoadedContextView] = useState(false);
  const [hooksStandaloneView, setShowHooksStandaloneView] = useState(false);
  const ContextKwikPikDispatchView = useKwikPikContextDispatchView();
  const HooksStandaloneKwikPikDispatchView = useStandaloneDispatchView({
    apiKey: "YOUR_API_KEY",
    mapsApiKey: "YOUR_GOOGLE_API_KEY",
    environment: "dev",
  });
  return (
    <div className="App">
      <ContextKwikPikDispatchView visible={showContextLoadedView} onClose={() => setShowLoadedContextView(false)} />
      <HooksStandaloneKwikPikDispatchView
        visible={hooksStandaloneView}
        onClose={() => setShowHooksStandaloneView(false)}
      />
      <button onClick={() => setShowLoadedContextView(true)}>Dispatch view with loaded context</button>
      <div style={{ marginLeft: 10, marginRight: 10 }}></div>
      <button onClick={() => setShowHooksStandaloneView(true)}>Standalone dispatch view with hooks</button>
    </div>
  );
}

export default App;

From the snapshot above, you can see that it is also possible to use a standalone dispatch view that doesn't depend on a context provider by calling useStandaloneDispatchView.

You can also use the DispatchView component directly and configure it like so:

import { DispatchView } from "@kwikpik/kwikpik-react";

<DispatchView
  apiKey="YOUR_API_KEY"
  mapsApiKey="YOUR_GOOGLE_MAPS_API_KEY"
  environment="prod"
  visible={true | false}
  onClose={() => {
    // Do something here
  }}
/>;

example