0.1.10 • Published 2 years ago

@vrisingdev/use-server-scanner-hook v0.1.10

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@vrisingdev/use-server-scanner-hook

Library for querying V Rising dedicated server data using ReactJS. This library is built with the V Rising Server Scanner API. If you have not already, click the link and register for an API key.

npm version Build Status Maintainability Downloads/week License: MIT

Getting Started

Installation

  • with NPM

    $ npm install @vrisingdev/use-server-scanner-hook

  • with Yarn

    $ yarn @vrisingdev/use-server-scanner-hook

Usage

index.js

Compose your entire app or the component that will be consuming the useServerScanner hook with the ServerScannerProvider component. Pass the V Rising Server Scanner API key to the provider via the apiKey prop.

...

import { ServerScannerProvider } from "@vrisingdev/use-server-scanner-hook";

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
  <React.StrictMode>
    <ServerScannerProvider apiKey={API_KEY}>
      <App />
    </ServerScannerProvider>
  </React.StrictMode>
);

FunctionalComponent.js

In a functional child component, import the useServerScanner hook and pass in a config object containing the host IP and query port of the V Rising server. This hook will return an object containing an error and data field. If the request is successful you will receive data. If the request fails, you'll receive an error message.

import { useServerScanner } from "@vrisingdev/use-server-scanner-hook";

function FunctionalComponent() {

  const { data, error } = useServerScanner({ host: HOST, queryPort: QUERY_PORT });
  
  ...
}

export default FunctionalComponent;

License

@vrisingdev/use-server-scanner-hook is licensed under the MIT License.