(props: { postId: number; setPostId: Setter<number> })
| 96 | } |
| 97 | |
| 98 | function Post(props: { postId: number; setPostId: Setter<number> }) { |
| 99 | const state = createPost(props.postId) |
| 100 | |
| 101 | return ( |
| 102 | <div> |
| 103 | <div> |
| 104 | <a onClick={() => props.setPostId(-1)} href="#"> |
| 105 | Back |
| 106 | </a> |
| 107 | </div> |
| 108 | <Switch> |
| 109 | <Match when={!props.postId || state.status === 'pending'}> |
| 110 | Loading... |
| 111 | </Match> |
| 112 | <Match when={state.status === 'error'}> |
| 113 | <span>Error: {(state.error as Error).message}</span> |
| 114 | </Match> |
| 115 | <Match when={state.data !== undefined}> |
| 116 | <> |
| 117 | <h1>{state.data?.title}</h1> |
| 118 | <div> |
| 119 | <p>{state.data?.body}</p> |
| 120 | </div> |
| 121 | <div>{state.isFetching ? 'Background Updating...' : ' '}</div> |
| 122 | </> |
| 123 | </Match> |
| 124 | </Switch> |
| 125 | </div> |
| 126 | ) |
| 127 | } |
| 128 | |
| 129 | const App: Component = () => { |
| 130 | const [postId, setPostId] = createSignal(-1) |
nothing calls this directly
no test coverage detected
searching dependent graphs…