Dashboard-Plugin
Docs HomeDashboard plugins and appsInfomakerNaviga global
  • About
  • Intro
  • Getting started
  • The anatomy of a plugin
  • Manifest structure
  • Getting started
    • Get Dashboard-Plugin
    • Build
  • What's new
  • Components
    • Agent
      • Actions
    • Application
    • Widget
    • Health
    • Modal
    • Settings
  • API and GUI
    • API
      • Overview
      • register
        • Reducers
        • Portals
        • Requirements
        • Permissions
        • Default config
        • Config Modifiers
      • cache
      • store
      • encrypt
      • decrypt
      • createUUID
      • getLanguage
      • getTextDirection
      • getTimeFormat
      • getKeyCharFromCode
      • getKeyCodeFromChar
      • event
      • Logger
      • buildRouteUrlWithDispatchableEvent
      • getUser
      • getAction
      • getPortal
      • getConfig
      • getLocalize
      • getAvailableActions
      • getAvailablePortals
      • request
      • setHealth
      • openModal
      • closeModal
      • confirm
      • notifications
      • hasPermission
      • standalone
      • withUser
      • useModal
      • useSheet
      • useUser
      • useConfig
      • useLocalize
      • useApplication
      • useMappings
      • useStandalone
    • GUI
      • Core GUI
      • Style-Guide
    • Modules
      • GUI
      • Utility
      • NavigaID
        • getUserToken
        • getApplicationToken
        • getGroupsFromToken
  • Mappings
  • Plugins deployments
  • S3 upload
  • Deprecations
    • 4.1.0
    • 4.0.0
    • 2.1.0
Powered by GitBook
On this page

Was this helpful?

  1. API and GUI
  2. API

getAction

You can use registered Actions by passing the Action id to getAction method from Plugin-API

How to use

import { Plugin } from '@root'

import {
    useRef,
    useState,
    useCallback
} from 'react'

const Application = () => {
    const fetchAction = useRef(getAction('my-fetch-action'))
    const loggerAction = useRef(getAction('my-logger-action'))

    const [data, setData] = useState(null)

    const handleOnLoadMore = useCallback(() => {
        fetchAction.current('www.my-data.endpoint.com/json')
            .then(payload => {
                setData(payload)
            })
            .catch(error => {
                loggerAction.current(error)
            })
    }, [])

    return (
        <button onClick={handleOnLoadMore}>
            {'Load more'}
        </button>
    )
}

export {
    Application
}
PreviousgetUserNextgetPortal

Last updated 4 years ago

Was this helpful?