File tree Expand file tree Collapse file tree 5 files changed +24
-27
lines changed
_official-realtime-app/app Expand file tree Collapse file tree 5 files changed +24
-27
lines changed Original file line number Diff line number Diff line change 11import type { LinksFunction , MetaFunction } from "@remix-run/node" ;
2+ import { json } from "@remix-run/node" ;
23import {
34 Links ,
45 Meta ,
@@ -52,6 +53,6 @@ function useRealtimeIssuesRevalidation() {
5253
5354// FIXME: Pointless action for revalidation until:
5455// https://github.com/remix-run/remix/issues/4485
55- export function action ( ) {
56- return { ok : true } ;
56+ export async function action ( ) {
57+ return json ( { ok : true } ) ;
5758}
Original file line number Diff line number Diff line change 1+ import { json } from "@remix-run/node" ;
12import { Link , useFetcher , useNavigate } from "@remix-run/react" ;
23import { useLoaderData } from "@remix-run/react" ;
34import classNames from "classnames" ;
45import { useEffect , useRef } from "react" ;
56
6- import { getIssues } from "../data " ;
7- import type { Issue } from ".. /data" ;
8- import * as AmalgoBox from "../amalgo-box.client " ;
9- import icons from ".. /icons.svg" ;
7+ import * as AmalgoBox from "~/amalgo-box.client " ;
8+ import type { Issue } from "~ /data" ;
9+ import { getIssues } from "~/data " ;
10+ import icons from "~ /icons.svg" ;
1011
11- export function loader ( ) {
12- return getIssues ( ) ;
12+ export async function loader ( ) {
13+ return json ( await getIssues ( ) ) ;
1314}
1415
1516export default function Index ( ) {
16- const issues = useLoaderData ( ) as Issue [ ] ;
17+ const issues = useLoaderData < typeof loader > ( ) ;
1718
1819 useEffect ( ( ) => AmalgoBox . registerCustomElements ( ) , [ ] ) ;
1920 return (
Original file line number Diff line number Diff line change 1- import { type DataFunctionArgs } from "@remix-run/node" ;
1+ import type { LoaderArgs } from "@remix-run/node" ;
22import { eventStream } from "remix-utils" ;
33
4- import { emitter , EVENTS } from ".. /events" ;
4+ import { emitter , EVENTS } from "~ /events" ;
55
6- export const loader = ( { request } : DataFunctionArgs ) => {
6+ export const loader = async ( { request } : LoaderArgs ) => {
77 return eventStream ( request . signal , ( send ) => {
88 const handler = ( message : string ) => {
99 send ( { data : message } ) ;
Original file line number Diff line number Diff line change 1+ import type { LoaderArgs , MetaFunction } from "@remix-run/node" ;
12import { json } from "@remix-run/node" ;
2- import type { DataFunctionArgs , SerializeFrom } from "@remix-run/node" ;
33import { useFetcher , useLoaderData } from "@remix-run/react" ;
44import invariant from "tiny-invariant" ;
55
66import { getIssue } from "~/data" ;
77
8- export const loader = async ( { params } : DataFunctionArgs ) => {
8+ export const loader = async ( { params } : LoaderArgs ) => {
99 invariant ( params . id , "Missing issue id" ) ;
1010 const issue = await getIssue ( params . id ) ;
1111 if ( ! issue ) {
1212 throw json ( "Issue not found" , { status : 404 } ) ;
1313 }
14- return issue ;
14+ return json ( issue ) ;
1515} ;
1616
17- export const meta = ( {
18- data : issue ,
19- } : {
20- data : SerializeFrom < typeof loader > ;
21- } ) => {
22- return {
23- title : issue ?. title || "Not Found" ,
24- } ;
25- } ;
17+ export const meta : MetaFunction < typeof loader > = ( { data : issue } ) => ( {
18+ title : issue ?. title || "Not Found" ,
19+ } ) ;
2620
2721export default function Issue ( ) {
2822 const issue = useLoaderData < typeof loader > ( ) ;
Original file line number Diff line number Diff line change 1- import { type DataFunctionArgs } from "@remix-run/node" ;
1+ import type { ActionArgs } from "@remix-run/node" ;
2+ import { json } from "@remix-run/node" ;
23import invariant from "tiny-invariant" ;
34
45import { updateIssue } from "~/data" ;
56import { emitter , EVENTS } from "~/events" ;
67
7- export const action = async ( { params, request } : DataFunctionArgs ) => {
8+ export const action = async ( { params, request } : ActionArgs ) => {
89 const updates = Object . fromEntries ( await request . formData ( ) ) ;
910 invariant ( params . id , "Missing issue id" ) ;
1011 const result = await updateIssue ( params . id , updates ) ;
1112 emitter . emit ( EVENTS . ISSUE_CHANGED , Date . now ( ) ) ;
12- return result ;
13+ return json ( result ) ;
1314} ;
You can’t perform that action at this time.
0 commit comments