Skip to content

Configurable Canvas Events #2948

Answered by CodyJasonBennett
arcasoy asked this question in Q&A
Discussion options

You must be logged in to vote

useState can accept a callback as a lazy initializer which it's consuming instead of merely storing a function. You'd have to wrap it as such when defining and setting it:

const [canvasEvents, setCanvasEvents] = useState<canvasEventsParametersWithoutUndefined>(() => (state: any) => ({
  // Default configuration
  ...events(state),

  // Determines if the event layer is active
  enabled: true,
}))

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by arcasoy
Comment options

You must be logged in to vote
1 reply
@arcasoy
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Issue is a question (may be converted to a discussion)
3 participants
Converted from issue

This discussion was converted from issue #2946 on July 26, 2023 09:32.