-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/add treecluster filter #40
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 👍 👍
Well done! Now I'm happy, now you don't skip the react render logic and everything works. I changed the router definition a little bit as well as the zod schema to get an array of strings, so you dont have to do it manually
status: z.array(z.string()).optional(), | ||
region: z.array(z.string()).optional(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have changed this to an array of strings, so you do not need to do this manually.
const search = useLoaderData({ from: '/_protected/treecluster/' }); | ||
|
||
const [statusTags, setStatusTags] = useState<string[]>(search.status); | ||
const [regionTags, setRegionTags] = useState<string[]>(search.region); | ||
|
||
useEffect(() => { | ||
if (search.status) setStatusTags(search.status); | ||
if (search.region) setRegionTags(search.region); | ||
}, [search.status, search.region]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And because we have parsed it in the router loader, we can access the data with the useLoaderData
hook.
loaderDeps: ({ search: { status, region } }) => ({ | ||
status: status || [], | ||
region: region || [], | ||
}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So now we can say that if it's not undefined, take the search param as an array, otherwise use an empty array.
refs #26