Skip to content

Commit e4a3e74

Browse files
docs: Moving images inline and changing urls to relative (#5072)
Incorporating feedback from PR - #4089. Changes made - 1. Moved images to `assets` folder on suggestion 2. Changed URLs from absolute to relative. 3. Adding an in-line sequence diagram <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Newly added jokes now receive unique identifiers, improving reliability when creating new entries. * **Documentation** * Updated links to internal paths for SSR, router concepts, and React Query sections. * Switched images to repository-hosted assets for consistency and availability. * Replaced the data flow image with an inline Mermaid sequence diagram covering home-page loading and add-joke flows, including data refresh behavior. * Minor formatting cleanup. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 1405da7 commit e4a3e74

File tree

4 files changed

+37
-8
lines changed

4 files changed

+37
-8
lines changed
185 KB
Loading
216 KB
Loading
244 KB
Loading

docs/start/framework/react/reading-writing-file.md

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ The complete code for this tutorial is available on [GitHub](https://github.com/
2626

2727
## Nice to know
2828

29-
- [Server Side Rendering (SSR)](https://tanstack.com/router/latest/docs/framework/react/guide/ssr)
30-
- [TanStack Router concepts](https://tanstack.com/router/latest/docs/framework/react/routing/routing-concepts)
31-
- [React Query concepts](https://tanstack.com/query/latest/docs/framework/react/overview)
29+
- [Server Side Rendering (SSR)](/router/latest/docs/framework/react/guide/ssr)
30+
- [TanStack Router concepts](/router/latest/docs/framework/react/routing/routing-concepts)
31+
- [React Query concepts](/query/latest/docs/framework/react/overview)
3232

3333
## Setting up a TanStack Start Project
3434

@@ -96,7 +96,7 @@ Once your project is set up, you can access your app at `localhost:3000`. You sh
9696

9797
At this point, your app will look like this -
9898

99-
![TanStack Start Welcome Page After Setup](https://res.cloudinary.com/dubc3wnbv/image/upload/v1746312482/Photo-1_lpechn.png)
99+
![TanStack Start Welcome Page After Setup](https://raw.githubusercontent.com/TanStack/router/main/docs/router/assets/reading-writing-file-setup.png)
100100

101101
## Step 1: Reading Data From a File
102102

@@ -164,7 +164,6 @@ Let's create a new file `src/serverActions/jokesActions.ts` to create a server f
164164
165165
```tsx
166166
// src/serverActions/jokesActions.ts
167-
168167
import { createServerFn } from '@tanstack/react-start'
169168
import * as fs from 'node:fs'
170169
import type { JokesData } from '../types'
@@ -247,7 +246,7 @@ When the page loads, `jokes` will have data from the `jokes.json` file already!
247246

248247
With a little Tailwind styling, the app should look like this:
249248

250-
![DevJoke App with 5 DevJokes](https://res.cloudinary.com/dubc3wnbv/image/upload/v1746313558/Screenshot_2025-05-03_at_4.04.50_PM_w0eern.png)
249+
![DevJoke App with 5 DevJokes](https://raw.githubusercontent.com/TanStack/router/main/docs/router/assets/reading-writing-file-devjokes-1.jpg)
251250

252251
## Step 2: Writing Data to a File
253252

@@ -445,7 +444,7 @@ export function JokeForm() {
445444
```
446445

447446
With this, our UI should look like this:
448-
![DevJoke App with Form to Add Jokes](https://res.cloudinary.com/dubc3wnbv/image/upload/v1746356983/Screenshot_2025-05-04_at_4.06.57_AM_dkgvsm.png)
447+
![DevJoke App with Form to Add Jokes](https://raw.githubusercontent.com/TanStack/router/main/docs/router/assets/reading-writing-file-devjokes-2.jpg)
449448

450449
## Understanding How It All Works Together
451450

@@ -472,7 +471,37 @@ Let's break down how the different parts of our application work together:
472471

473472
### Data Flow
474473

475-
![Data Flow Diagram](https://res.cloudinary.com/dubc3wnbv/image/upload/v1746437057/Screenshot_2025-05-05_at_2.23.11_AM_wxfz2m.png)
474+
```mermaid
475+
sequenceDiagram
476+
autonumber
477+
actor User
478+
participant UI as Browser (HomePage + Form)
479+
participant Loader as Route Loader (loader)
480+
participant Server
481+
participant Store as jokes.json
482+
483+
%% Visiting the Home Page
484+
User ->> UI: Visit /
485+
UI ->> Loader: loader() calls getJokes()
486+
Loader ->> Server: getJokes()
487+
Server ->> Store: Read jokes.json
488+
Store -->> Server: jokes data
489+
Server -->> Loader: jokes[]
490+
Loader -->> UI: useLoaderData() → jokes[]
491+
492+
%% Adding a New Joke
493+
User ->> UI: Fill form and submit
494+
UI ->> Server: handleSubmit → addJoke(newJoke)
495+
Server ->> Store: Read jokes.json
496+
Server ->> Store: Write updated jokes.json
497+
Server -->> UI: addJoke() resolved
498+
UI ->> Loader: router.invalidate() (re-run loader)
499+
Loader ->> Server: getJokes()
500+
Server ->> Store: Read jokes.json
501+
Store -->> Server: updated jokes[]
502+
Server -->> Loader: updated jokes[]
503+
Loader -->> UI: useLoaderData() → updated jokes[]
504+
```
476505

477506
When a user visits the home page:
478507

0 commit comments

Comments
 (0)