@niksharma1997
nik72619c
dev-nik.netlify.com
The old school approach
The solution : Optimistic UI
Why use it ?
how it improves UX
BUILDING IS GOOD , BUT ARE YOU BUILDING SOMETHING USEFUL ?
=
No loading states
greater a11y !
UI seems faster irrespective of the network bottleneck
const LIKE_QUERY = gql`
query getLike{
getLike
}
`;
const INCREMENT = gql`
mutation increment($value: Int!){
increment(value: $value)
}
`;
const like = ()=>{
console.log('called');
increment({
variables: {
value: 1
},
optimisticResponse: {
__typename: 'mutation',
increment: value+1
}
});
}
REFERENCES:-
https://github.com/nik72619c/