How to use hox - 4 common examples

To help you get started, we’ve selected a few hox 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 sorrycc / learn-react-with-umi / hox / hooks / useCount.js View on Github external
import { useState } from 'react';

function useCount() {
  const [count, setState] = useState(0);

  function increment() {
    setState(count + 1);
  }

  return {
    count,
    increment,
  };
}

export default createModel(useCount);
export { useCount as useLocalCount };
github DFocusGroup / generator-umi / generators / app / templates / src / hooks / useAuthModel.js View on Github external
}, [])

  const signout = useCallback((account, password) => {
    clearAll()
    setCurrentUser(null)
    setTokenState(null)
  }, [])

  return {
    currentUser,
    sign,
    signout
  }
}

export default createModel(useAuthModel)
github leftstick / hosts-high / src / renderer / stores / useHostsModel.js View on Github external
useEffect(() => {
    getSysHosts(aliases).then(sysHosts => {
      setSysHosts(sysHosts)
    })
  }, [aliases])

  return {
    hosts,
    createHost,
    toggleHostState,
    removeHost,
    modifyHost
  }
}

export default createModel(useHostsModel)

function getSysHosts(aliases) {
  return new Promise(function(resolve, reject) {
    hostile.get(false, function(error, lines) {
      if (error) {
        return reject(error.message)
      }
      const sysHosts = lines.map(line => {
        const ip = line[0]
        const domain = line[1]
        return {
          ip: ip,
          domain: domain,
          disabled: false,
          alias: aliases[ip + domain] || ''
        }
github leftstick / hosts-high / src / renderer / stores / usePermissionModel.js View on Github external
},
        () => {
          setAcquired(false)
          return false
        }
      )
    })
  }

  return {
    acquired,
    permissionAcquired
  }
}

export default createModel(usePermissionModel)

function requestPermission() {
  const options = {
    name: 'Hosts Master'
  }
  return new Promise(function(resolve, reject) {
    sudo.exec(PERMISSION_CMD, options, function(err) {
      if (err) {
        return reject(err)
      }
      return resolve()
    })
  })
}

hox

React store with hooks.

MIT
Latest version published 1 year ago

Package Health Score

52 / 100
Full package analysis

Popular hox functions

Similar packages