0.0.1 • Published 4 months ago

react-meteor-method-hooks v0.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
4 months ago

react-meteor-method-hooks

Simple hook to handle Meteor.call requests.

Usage example:

import React from 'react';
import { useMeteorCall } from 'react-meteor-method-hooks';

const MyComponent = () => {

  const [
    calculateSomething, 
    calculateSomethingLoading, 
    calculateSomethingError, 
    calculateSomethingResult
  ] = useMeteorCall(
    'calculateSomethingMethodName',
    {},
    (error, result) => {
      if (error) {
        alert(error.reason);
      } else {
        console.log(result);
      }
    },
  );

  return (
    <button 
      onClick={calculateSomething} 
      disabled={calculateSomethingLoading}
    >
      Calculate
    </button>

    <div className="error">{calculateSomethingError}</div>
    <div className="result">{calculateSomethingResult}</div>
  )
}
0.0.2-beta.5

4 months ago

0.0.2-beta.3

5 months ago

0.0.2-beta.4

5 months ago

0.0.2-beta.1

5 months ago

0.0.2-beta.2

5 months ago

0.0.1

3 years ago

1.0.0

3 years ago