Utility

Available utilities

How to use

import { useState } from 'react'

import {
    GUI,
    Utility
} from '@root'

/*
    OR you can import from the modules import name
    import { Utility } from 'Dashboard/modules'
*/

const {
    DateFNS
} = Utility

const App = () => {
    const [dateValue, setDateValue] = useState(new Date())
    
    const handleNextDay = () => {
        const updatedDate = DateFNS.addDays(dateValue, 1)
        setDateValue(updatedDate)
    }
    
    const handlePreviousDay = () => {
        const updatedDate = DateFNS.subDays(dateValue, 1)
        setDateValue(updatedDate)
    }
    
    return (
        <div>
            <GUI.Button onClick={handleNextDay}>
                {'Next day'}
            </GUI.Button>

            <p>{DateFNS.format(dateValue)}</p>
            
            <GUI.Button onClick={handlePreviousDay}>
                {'Previous day'}
            </GUI.Button>
        </div>
    )
}

export default App

With Dashboard-Plugin base from version 2.0.0, we export Utility from '@root' so you can import API methods and Utility from the same import name

Last updated