Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
| import { createContext, useContext } from 'react'; | ||
|
|
||
| interface FeedCardContextData { | ||
| isBoostedReach: boolean; | ||
| } | ||
|
|
||
| export const FeedCardContext = createContext<FeedCardContextData>({ | ||
| isBoostedReach: false, | ||
| }); | ||
|
|
||
| export const useFeedCardContext = (): FeedCardContextData => | ||
| useContext(FeedCardContext); |
There was a problem hiding this comment.
Use the createContextProvider from @kickass-coderz/react to generate both of these in single function.
See https://github.com/dailydotdev/apps/blob/546082bd6fe3954747909b8bfe4593a8430792db/packages/shared/src/contexts/search/SearchContext.tsx
There was a problem hiding this comment.
Wait let me check quickly.
There was a problem hiding this comment.
The problem is, I don't need a managed state, I just need to pass down some values.
There was a problem hiding this comment.
It's just a wrapper of useContext, but easier to use.
There was a problem hiding this comment.
I tried it, but didn't work for me 😢
It was not allowing me to pass props down to the provider that was generated.
There was a problem hiding this comment.
There is always that one guy moment (a guy that uses interface :lolsob:).
There was a problem hiding this comment.
@capJavert is there a way to set a default value? Unfortunately, I had to revert at the moment because the areas where I am trying to pull the context break. We need to have a way to set a default value of the Context for when the provider is not present.
I'd be glad to raise another PR for this 😉
Tests with the util:
https://app.circleci.com/pipelines/github/dailydotdev/apps/27367/workflows/03d8b707-2836-43f1-990d-7e008dfc66ce/jobs/93218
After revert is what we have now.
Commit:
720efbd
There was a problem hiding this comment.
Throwing when there is not context is by design. Yeah if it does not fit feel free to do it by hand. I'll look if we can add support for it.
There was a problem hiding this comment.
Ah, I see. I mean it makes sense if the consuming end strictly needs proper values.
This reverts commit d575953.
rebelchris
left a comment
There was a problem hiding this comment.
Think we need to move this context file out of this folder :)
| isBoostedReach: boolean; | ||
| }; | ||
|
|
||
| export const FeedCardContext = createContext<FeedCardContextData>({ |
There was a problem hiding this comment.
But then let's move it out of the boost feature folder?
And just make it value <Optional> no?
| const { mutateAsync: onCancelBoost } = useMutation({ | ||
| mutationFn: cancelPostBoost, | ||
| onSuccess: async () => { | ||
| await client.invalidateQueries({ |
There was a problem hiding this comment.
So much invalidation can't we do it optimistic?
There was a problem hiding this comment.
We can't because this involves integration with another service that requires value from there.
| index: adPage, | ||
| updatedAt: adsUpdatedAt, | ||
| }; | ||
| // TODO: remove this once integration comes in |
Changes
Events
Did you introduce any new tracking events?
Experiment
Did you introduce any new experiments?
Manual Testing
Caution
Please make sure existing components are not breaking/affected by this PR
Jira ticket
MI-888
Preview domain
https://mi-888-ad.preview.app.daily.dev