@connected/react
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

@connected/hooks

An experimental React hooks package that makes using the connected package easy in React apps.

Usage

// article.tsx
import React from 'react';
import { useResult } from '@connected/hooks';
import { findArticle } from './article.server';

const Article = ({ id }) => {
  const { title, intro } = useResult(findArticle, id);
  return (       
    <React.Fragment> 
      <h1>{title}</h1>
      <article>
        <p>{intro}</p>
      </article>
    </React.Fragment>);
}
// article.server.tsx                    
type Article = {
  title: string; 
  intro: string;
}
export async function findArticle(id: string): Promise<Article> {
  // This is Server! Load the article from database
}

/@connected/react/

    Package Sidebar

    Install

    npm i @connected/react

    Weekly Downloads

    13

    Version

    0.1.1

    License

    ISC

    Unpacked Size

    47.8 kB

    Total Files

    63

    Last publish

    Collaborators

    • martinkomara