(props: { postId: number; setPostId: Setter<number> })
| 140 | } |
| 141 | |
| 142 | function Post(props: { postId: number; setPostId: Setter<number> }) { |
| 143 | const state = createPost(() => props.postId) |
| 144 | |
| 145 | return ( |
| 146 | <div> |
| 147 | <div> |
| 148 | <a onClick={() => props.setPostId(-1)} href="#"> |
| 149 | Back |
| 150 | </a> |
| 151 | </div> |
| 152 | <Switch> |
| 153 | <Match when={!props.postId || state.status === 'pending'}> |
| 154 | Loading... |
| 155 | </Match> |
| 156 | <Match when={state.status === 'error'}> |
| 157 | <span>Error: {(state.error as Error).message}</span> |
| 158 | </Match> |
| 159 | <Match when={state.data !== undefined}> |
| 160 | <> |
| 161 | <h1>{state.data?.title}</h1> |
| 162 | <div> |
| 163 | <p>{state.data?.body}</p> |
| 164 | </div> |
| 165 | <div>{state.isFetching ? 'Background Updating...' : ' '}</div> |
| 166 | </> |
| 167 | </Match> |
| 168 | </Switch> |
| 169 | </div> |
| 170 | ) |
| 171 | } |
| 172 | |
| 173 | render(() => <App />, document.getElementById('root') as HTMLElement) |
nothing calls this directly
no test coverage detected
searching dependent graphs…