Skip to content
Discussion options

You must be logged in to vote

useHeadlessFlatTree allows you to pass a controlled value of checkedItems and a callback to when you should update that state with onChekcedChange, with that you can take control of the checked state. Once in control of the checked state, to reset it simply set the state to be an empty iterable (like a map, or an array for example).

Here's an updated version of your code: https://codesandbox.io/s/awesome-wescoff-rxxyhr?file=/src/example.tsx

Also, here's a TS playground link just in case the codesandbox goes down:

export const Selection = () => {
  const [checkedItems, setCheckedItems] = React.useState(
    () => new Map<TreeItemValue, TreeSelectionValue>([["1-2", true]])
  );
  const flat…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@chiim
Comment options

@bsunderhus
Comment options

Answer selected by chiim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants