Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
why does github have statuses?

Robert Balicki rbalicki2

💭
why does github have statuses?
  • Facebook
  • NYC
View GitHub Profile
View rendering-the-api-call.rs
{
search_api_call_opt.as_ref().map(|ref mut search_api_call| {
match &mut *search_api_call.borrow_mut() {
PromiseState::Success(search_results) => {
let search_results = search_results.clone();
render_search_results(search_results, |track_id| {
page.go_to_detail_view(track_id);
})
},
PromiseState::Pending => smd!(<p>Loading</p>),
View match-example.rs
{
match page {
Page::Search(search_api_call) => ...
}
}
@rbalicki2
rbalicki2 / new_hooks_api_based_pagination.react.jsx
Last active Mar 31, 2021
Comparison of pagination without and without Relay Hooks
View new_hooks_api_based_pagination.react.jsx
/**
* This file shows an example of pagination using the new Relay Hooks
* APIs. Please see old_container_based_api.react.jsx for an example of
* how this might have looked using the previous, Container-based APIs.
*/
'use strict';
import type {UserComponent_user$key} from 'UserComponent_user.graphql';
@rbalicki2
rbalicki2 / new_hooks_based_refetching.react.jsx
Last active Mar 7, 2021
Comparison of Hooks and Container-based Refetching
View new_hooks_based_refetching.react.jsx
type Props = {
comment: CommentBody_comment$key,
};
function CommentBody(props: Props) {
const [data, refetch] = useRefetchableFragment<CommentBodyRefetchQuery, _>(
graphql`
fragment CommentBody_comment on Comment
@refetchable(queryName: "CommentBodyRefetchQuery") {
body(lang: $lang) {
text