0.0.1 • Published 4 years ago

react-farcry v0.0.1

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

react-farcry

React utilities for FarCry.

Experimental!

Usage

import { useMethod, refresh } from "react-farcry";
import { getPost, likePost } from "./rpc-client";

function Post(props: PostProps) {
  const post = useMethod(getPost, { postId: props.id });

  if (post === undefined) {
    return "Loading post...";
  }

  return (
    <div className="Post">
      <PostBody post={post} />
      <LikeButton
        liked={post.liked}
        onLike={async () => {
          await likePost({ postId: props.id });
          refresh(getPost);
        }}
      />
    </div>
  );
}