How to use react-use-promise - 3 common examples

To help you get started, we’ve selected a few react-use-promise examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github qlik-oss / catwalk / src / components / model.jsx View on Github external
function useTablesAndKeys(app, appLayout) {
  const [tablesAndKeys] = usePromise(() => app.getTablesAndKeys({}, {}, 0, true, false), [appLayout.qLastReloadTime]);
  return tablesAndKeys;
}
github LiskHQ / lisk-desktop / src / components / screens / wallet / send / form / useProcessingSpeed.js View on Github external
const useProcessingSpeed = () => {
  const { t } = useTranslation();
  const [dynamicFees = {}, error, status] = usePromise(getDynamicFees, []);
  const isLoading = status === 'pending';

  const [processingSpeedState, setProcessingSpeedState] = useState({
    value: 0,
    isLoading,
    selectedIndex: 0,
  });

  const selectProcessingSpeed = ({ item, index }) => {
    setProcessingSpeedState({
      ...processingSpeedState,
      ...item,
      selectedIndex: index,
      isLoading,
      error: !!error,
    });
github qlik-oss / catwalk / src / components / use / model.jsx View on Github external
export default function useModel(app, def) {
  const [model, error] = usePromise(() => app.getOrCreateObject(def), [app.id + JSON.stringify(def)]);
  if (error) throw error;
  return model;
}

react-use-promise

React hook for handling promises.

MIT
Latest version published 2 years ago

Package Health Score

48 / 100
Full package analysis

Popular react-use-promise functions