Open dnhn opened 1 year ago
Great work 👍
Result: ✅
IButton
interface should be in the same folder as the Button component. E.g. something like this:components/
Button/
Button.tsx
types.ts // <-- put it here
...
setSearch
, setPageIndex
, etc. (from useState
) will not trigger rerender, so there's no need to memoize them:const [params, setParams] = useState({
q: '',
page: 1,
pageSize: 5,
...
})
useEffect(() => {
push(...)
}, [params])
You can also look for 3rd party packages such as query-string
to help with converting an object into query string.
You should also be able to extract the params management logic into a reusable hook 🤔
For example, we can do something like:
<>
<button onClick={openDeleteBookDialog}>Delete</button>
<DeleteBookDialog open={open} ... />
</>
Basically what we normally see in UI library like MUI. This should help you cut out the BooksDialogContext
and keep the codebase a bit cleaner.
https://dffe23-dn-4.vercel.app