How to type object like this as props
Heyy I play a little with trpc and optimistic updates and I wonder how can I type object like this when I pass it as props.
then
4 Replies
what do you want to achieve by putting that mutation inside an object
bc it's a bit unusual and the type of addTodo is huge
https://create.t3.gg/en/usage/trpc/#optimistic-updates i just copied example from the docs to use optimistic updates. I wanted to pass it as props because too different components use this add todo, so didnt wanted repeat myself. For now I choosed to extract all logic inside useTodos hook and just use it something like this:
i think you're on the right track
I think the hook idea is much better than passing it as props