Forge UI - how do I create a hook to update a state property?

322 Views Asked by At

I'm trying to set a state property by using a Forge UI kit hook, like this:

const sortOrder [orderBy, setSortOrder] = useAction(
    ( currentSortOrder, nextSortOrder: string ) => nextSortOrder, "word");

Forge UI hooks work in a similar way to React hooks. An intro video for how to use a Forge UI hook is here (watch from 15:45 - https://www.youtube.com/watch?v=WoSR7qQkgn4)

I'm getting the error An argument for 'initialValue' was not provided, but I've used the syntax according to the above video, and I intend "word" to be the initial value. How do I correct the code for the hook?

1

There are 1 best solutions below

0
On

Doh

const [orderBy, setSortOrder] = useAction( ( currentSortOrder, nextSortOrder: string ) => nextSortOrder, "word");