<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by atilla baspinar on Medium]]></title>
        <description><![CDATA[Stories by atilla baspinar on Medium]]></description>
        <link>https://medium.com/@atillabaspinar?source=rss-cd2bdb7a529b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*YYWrRX4OuKqZzMaC.</url>
            <title>Stories by atilla baspinar on Medium</title>
            <link>https://medium.com/@atillabaspinar?source=rss-cd2bdb7a529b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 22:27:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@atillabaspinar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Angular Modules (a refresher that you might not need)]]></title>
            <link>https://medium.com/@atillabaspinar/angular-modules-a-refresher-that-you-might-not-need-a5b0e5de9863?source=rss-cd2bdb7a529b------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5b0e5de9863</guid>
            <category><![CDATA[angular-module]]></category>
            <category><![CDATA[standalone-component]]></category>
            <dc:creator><![CDATA[atilla baspinar]]></dc:creator>
            <pubDate>Mon, 22 Jun 2026 10:47:46 GMT</pubDate>
            <atom:updated>2026-06-22T10:47:46.352Z</atom:updated>
            <content:encoded><![CDATA[<p>This is the second article of my series of Angular. In this one, i cover Modules and describe how they may coexist with the modern approach, stand-alone components. <br>See my first article for Angular essentials here: <a href="https://medium.com/@atillabaspinar/angular-concepts-in-nutshell-incl-angular-21-951e07a6e505">https://medium.com/@atillabaspinar/angular-concepts-in-nutshell-incl-angular-21-951e07a6e505</a></p><h3>1. What is an NgModule</h3><p>An NgModule groups related components, directives, and pipes together. It was the primary way to structure Angular apps before standalone components arrived in Angular 14.</p><p>NgModules are <strong>not deprecated</strong> — they are still fully supported in Angular 21. Only platformBrowserDynamic (the old bootstrap function) was deprecated. The recommended path for new projects is standalone components, but NgModules remain valid for existing codebases.</p><h3>2. NgModule Anatomy</h3><p>The @NgModule decorator accepts five main properties:</p><ul><li><strong>declarations</strong> — Non-standalone components, directives, and pipes owned by this module</li><li><strong>imports</strong> — Other NgModules or standalone components/pipes this module needs</li><li><strong>exports</strong> — What this module exposes to other modules that import it</li><li><strong>providers</strong> — Services to register (prefer providedIn: &#39;root&#39; on the service itself)</li><li><strong>bootstrap</strong> — The root component Angular renders on startup — root module only</li><li>@NgModule({ declarations: [App], bootstrap: [App], imports: [BrowserModule, CommonModule, Tasks, NewTask, Task, User, Header, RouterOutlet], }) export class AppModule {}</li></ul><h3>3. declarations vs imports</h3><p>This is the most common source of confusion when mixing modules with standalone components.</p><ul><li><strong>declarations</strong> — only for <strong>non-standalone</strong> components (standalone: false). They are private to this module unless explicitly exported.</li><li><strong>imports</strong> — for other NgModules and for <strong>standalone</strong> components, directives, and pipes (the default since Angular 17).</li></ul><p>Putting a standalone component in declarations causes a compile error. Putting a non-standalone component in imports also causes an error.</p><p>Non-standalone component — belongs in declarations:</p><pre>@Component({<br>  standalone: false,<br>  selector: &#39;app-root&#39;,<br>  templateUrl: &#39;./app.html&#39;,<br>  styleUrl: &#39;./app.css&#39;,<br>})<br>export class App {}</pre><p>Standalone component (Angular 17+ default) — belongs in imports, not declarations:</p><pre>@Component({<br>  selector: &#39;app-header&#39;,<br>  templateUrl: &#39;./header.html&#39;,<br>})<br>export class Header {}</pre><pre>@NgModule({<br>  declarations: [App],<br>  imports: [BrowserModule, Header, RouterOutlet],<br>  bootstrap: [App],<br>})<br>export class AppModule {}</pre><p>A non-standalone component also <strong>cannot</strong> have an imports array in @Component — it delegates all imports to its module.</p><h3>4. BrowserModule vs CommonModule</h3><ul><li><strong>BrowserModule</strong> — root module only. Sets up the browser platform and includes CommonModule internally.</li><li><strong>CommonModule</strong> — feature modules. Provides NgIf, NgFor, NgClass, pipes, etc.</li></ul><p>Never import BrowserModule in a feature module — import CommonModule instead. Importing BrowserModule twice throws a runtime error.</p><h3>5. Bootstrapping with NgModule</h3><p>Use platformBrowser().bootstrapModule() from @angular/platform-browser. The older platformBrowserDynamic from @angular/platform-browser-dynamic was deprecated in Angular 21.</p><pre>// main.ts<br>import { platformBrowser } from &#39;@angular/platform-browser&#39;;<br>import { AppModule } from &#39;./app/app.module&#39;;</pre><pre>platformBrowser().bootstrapModule(AppModule)<br>  .catch((err: unknown) =&gt; console.error(err));</pre><h3>6. Feature Modules</h3><p>Feature modules group a slice of the app (e.g. tasks, users) to keep AppModule small. They export only what the rest of the app needs.</p><pre>// tasks/tasks.module.ts<br>import { NgModule } from &#39;@angular/core&#39;;<br>import { CommonModule } from &#39;@angular/common&#39;;<br>import { TasksComponent } from &#39;./tasks.component&#39;;</pre><pre>@NgModule({<br>  declarations: [TasksComponent],<br>  imports: [CommonModule],<br>  exports: [TasksComponent],<br>})<br>export class TasksModule {}</pre><pre>// app.module.ts<br>@NgModule({<br>  declarations: [App],<br>  imports: [BrowserModule, TasksModule],<br>  bootstrap: [App],<br>})<br>export class AppModule {}</pre><h3>7. Lazy-Loaded Feature Modules</h3><p>Lazy loading defers loading a module’s bundle until the user navigates to its route. Configure it with loadChildren in the router:</p><pre>// app.routes.ts<br>export const routes: Routes = [<br>  {<br>    path: &#39;tasks&#39;,<br>    loadChildren: () =&gt;<br>      import(&#39;./tasks/tasks.module&#39;).then((m) =&gt; m.TasksModule),<br>  },<br>];</pre><pre>// tasks/tasks.module.ts — use forChild, not forRoot<br>@NgModule({<br>  declarations: [TasksComponent],<br>  imports: [<br>    CommonModule,<br>    RouterModule.forChild([{ path: &#39;&#39;, component: TasksComponent }]),<br>  ],<br>})<br>export class TasksModule {}</pre><p>The root module uses RouterModule.forRoot(routes). Feature modules use RouterModule.forChild(routes).</p><h3>8. NgModule vs Standalone</h3><p><strong>NgModule:</strong></p><ul><li>Grouping: explicit module files</li><li>Sharing: export from module, then import the module</li><li>Lazy loading: loadChildren</li><li>Recommended for new projects: No</li><li>Deprecated: No</li></ul><p><strong>Standalone:</strong></p><ul><li>Grouping: no module file needed</li><li>Sharing: import the component directly</li><li>Lazy loading: loadComponent</li><li>Recommended for new projects: Yes</li></ul><p>NgModules are still valid and fully supported. Understanding them is essential for working with existing Angular codebases.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5b0e5de9863" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular Concepts in Nutshell (incl. Angular 21)]]></title>
            <link>https://medium.com/@atillabaspinar/angular-concepts-in-nutshell-incl-angular-21-951e07a6e505?source=rss-cd2bdb7a529b------2</link>
            <guid isPermaLink="false">https://medium.com/p/951e07a6e505</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[angular-signals]]></category>
            <category><![CDATA[angular-zoneless]]></category>
            <dc:creator><![CDATA[atilla baspinar]]></dc:creator>
            <pubDate>Sun, 21 Jun 2026 20:55:35 GMT</pubDate>
            <atom:updated>2026-06-21T21:29:35.141Z</atom:updated>
            <content:encoded><![CDATA[<p>The last Angular version I used was 12. Hence I want to have a review of what has changed. Surprisingly not much. The biggest change is to remove Zone.js gradually. Angular 17 seems to have the major changes. In the list below I noted each Angular essential feature. I will go on adding to the list as I study the concepts. I plan this to be an exhaustive cheatsheet in the end.</p><p>I have referenced which version of Angular the feature was introduced, become stable or, default, when it was necessary so that you may cross check your version and decide what to use.</p><p><strong>This is not a tutorial. You are supposed the know the concepts already</strong>. This is planned to be an exhaustive cheat-sheet or reference when you need a quick refresher.</p><h3>1. Template Member Access</h3><p>Any <strong>public</strong> member of the class can be used in the template. Private members are not accessible and will cause a TypeScript error in strict mode.</p><h3>2. Standalone Components</h3><p><strong>Standalone</strong> components (standalone: true) are the default since <strong>Angular 17</strong>. A component does not need to be declared inside an NgModule.</p><h3>3. String Interpolation</h3><p>Output any member value as text using double curly braces:</p><pre>&lt;p&gt;{{ username }}&lt;/p&gt;</pre><h3>4. Property Binding</h3><p>Binds an expression to a DOM element <strong>property</strong> (not an HTML attribute):</p><pre>&lt;img [src]=&quot;imageUrl&quot; /&gt;<br>&lt;button [disabled]=&quot;isLoading&quot;&gt;Submit&lt;/button&gt;</pre><h3>5. Attribute Binding</h3><p>A separate mechanism used when no corresponding DOM property exists for an HTML attribute (e.g. ARIA attributes, colspan):</p><pre>&lt;td [attr.colspan]=&quot;colSpan&quot;&gt;&lt;/td&gt;<br>&lt;button [attr.aria-label]=&quot;label&quot;&gt;Click&lt;/button&gt;</pre><h3>6. @Input() Decorator</h3><p>The old-style @Input() decorator relies on Zone.js-based change detection (dirty checking). Angular wraps browser events via Zone.js to know when to re-run change detection.</p><pre>@Input() user: User;</pre><h3>7. Signals</h3><p>The new reactive primitive. Introduced in Angular 16, become stable in Angular 20 (I will deep dive in signals in following articles).</p><p>Declare a signal and call it as a function to read its value — both in the template and inside the class:</p><pre>// in the class<br>selectedUser = signal(DUMMY_USERS[0]);<br>// read inside the class<br>const name = this.selectedUser().name; // not the function call!<br><br><br>&lt;!-- in the template --&gt;<br>&lt;p&gt;{{ selectedUser().name }}&lt;/p&gt;</pre><h3>8. Computed Signals</h3><p>Use computed() for derived values. A computed signal re-evaluates automatically when its dependencies change:</p><pre>import { computed, signal } from &#39;@angular/core&#39;;<br>selectedUser = signal(DUMMY_USERS[0]);<br>username = computed(() =&gt; this.selectedUser().name);<br><br>// read it like any other signal<br>const name = this.username();<br><br><br>// in the template<br>&lt;p&gt;{{ username() }}&lt;/p&gt;</pre><h3>9. Signal Inputs — input()</h3><p>Replaces @Input(). Signal inputs are read-only — you cannot call .set() on them:</p><pre>// optional with a default value<br>user = input(&#39;default&#39;);<br>// required (throws if not provided by parent)<br>user = input.required&lt;User&gt;();<br>// equivalent old-style decorator<br>@Input({ required: true }) user!: User;</pre><p>Because signal inputs are read-only, this.user.set(value) is not allowed.</p><h3>10. @Output() Decorator</h3><p>Lets a child component notify its parent by emitting events through an EventEmitter.</p><p><strong>Child component:</strong></p><pre>import { Component, Output, EventEmitter } from &#39;@angular/core&#39;;<br>@Output() userSelected = new EventEmitter&lt;User&gt;();<br>selectedUser: User = DUMMY_USERS[0];<br>onSelectUser() {<br>  this.userSelected.emit(this.selectedUser);<br>}</pre><p><strong>Child template:</strong></p><pre>&lt;button (click)=&quot;onSelectUser()&quot;&gt;Select User&lt;/button&gt;</pre><p><strong>Parent template</strong> (listen to the event with $event to receive the emitted value):</p><pre>&lt;app-user (userSelected)=&quot;selectUser($event)&quot; /&gt;</pre><h3>11. output() Function</h3><p>The decorator-free replacement for @Output() + EventEmitter (<strong>Angular 17.3+</strong>). It is <strong>not a signal</strong> — it returns an OutputEmitterRef&lt;T&gt;, which is emit-only and cannot be read like a signal. It belongs to the same decorator-free API family as input() and model().</p><p><strong>Child component:</strong></p><pre>import { Component, output, signal } from &#39;@angular/core&#39;;<br>selectedUser = signal(DUMMY_USERS[0]);<br>userSelected = output&lt;User&gt;();  // OutputEmitterRef&lt;User&gt;, not a Signal<br>onSelectUser() {<br>  this.userSelected.emit(this.selectedUser());<br>}t</pre><p><strong>Child template:</strong></p><pre>&lt;button (click)=&quot;onSelectUser()&quot;&gt;Select User&lt;/button&gt;</pre><p><strong>Parent template</strong> (identical to @Output() usage):</p><pre>&lt;app-user (userSelected)=&quot;selectUser($event)&quot; /&gt;</pre><p>Key differences from @Output(): no EventEmitter, no decorator. Unlike input(), you cannot call this.userSelected() to read a value — it only has .emit().</p><h3>12. @for — List Rendering</h3><p>Built-in control flow for rendering lists (<strong>Angular 17+</strong>). track is required and tells Angular how to identify each item across re-renders — similar to key in React. Prefer tracking by a unique id over $index when available.</p><pre>&lt;ul&gt;<br>  @for (user of users; track user.id) {<br>    &lt;li&gt;{{ user.name }}&lt;/li&gt;<br>  }<br>&lt;/ul&gt;</pre><p>@for also exposes implicit variables: $index, $first, $last, $even, $odd.</p><pre>@for (user of users; track user.id) {<br>  &lt;li [class.last]=&quot;$last&quot;&gt;{{ $index + 1 }}. {{ user.name }}&lt;/li&gt;<br>}</pre><p><strong>Before Angular 17</strong> — *ngFor structural directive (must be imported from CommonModule or NgFor):</p><pre>&lt;li *ngFor=&quot;let user of users; trackBy: trackById&quot;&gt;{{ user.name }}&lt;/li&gt;<br><br>...<br><br>// in the component<br>trackById(index: number, user: User) {<br>  return user.id;<br>}</pre><h3>13. @if / @else — Conditional Rendering</h3><p>Built-in control flow for conditional rendering (<strong>Angular 17+</strong>):</p><pre>@if (isLoggedIn) {<br>  &lt;p&gt;Welcome back, {{ username() }}!&lt;/p&gt;<br>} @else {<br>  &lt;p&gt;Please log in.&lt;/p&gt;<br>}</pre><p>You can also chain @else if:</p><pre>@if (status === &#39;loading&#39;) {<br>  &lt;p&gt;Loading...&lt;/p&gt;<br>} @else if (status === &#39;error&#39;) {<br>  &lt;p&gt;Something went wrong.&lt;/p&gt;<br>} @else {<br>  &lt;p&gt;{{ data }}&lt;/p&gt;<br>}</pre><p><strong>Before Angular 17</strong> — *ngIf structural directive (must be imported from CommonModule or NgIf). The else branch requires an &lt;ng-template&gt; with a reference variable:</p><pre>&lt;p *ngIf=&quot;isLoggedIn; else loggedOut&quot;&gt;Welcome back!&lt;/p&gt;<br>&lt;ng-template #loggedOut&gt;&lt;p&gt;Please log in.&lt;/p&gt;&lt;/ng-template&gt;</pre><h3>14. Class &amp; Style Binding</h3><p>Conditionally apply a CSS class based on a boolean expression:</p><pre>&lt;!-- single class --&gt;<br>&lt;div [class.active]=&quot;isActive&quot;&gt;&lt;/div&gt;<br><br>&lt;!-- multiple classes via object --&gt;<br>&lt;div [ngClass]=&quot;{ active: isActive, disabled: isDisabled }&quot;&gt;&lt;/div&gt;</pre><p>For inline styles, use [style.property] or [ngStyle]:</p><pre>&lt;div [style.color]=&quot;isError ? &#39;red&#39; : &#39;black&#39;&quot;&gt;&lt;/div&gt;</pre><h3>15. Two-Way Binding — ngModel</h3><p>Import FormsModule in the component&#39;s imports array, then use [(ngModel)] on an input. Each input must also have a name attribute for FormsModule to track it.</p><pre>import { FormsModule } from &#39;@angular/forms&#39;;<br>@Component({<br>  imports: [FormsModule],<br>  ...<br>})<br>export class MyComponent {<br>  title = &#39;&#39;;<br>}<br><br>-- in the template<br>&lt;input [(ngModel)]=&quot;title&quot; name=&quot;title&quot; /&gt;</pre><p><strong>With a writable signal</strong>, [(ngModel)] does not work correctly — even though the template compiles without error (because ngModel accepts any). At runtime, [(ngModel)]=&quot;title&quot; desugars to [ngModel]=&quot;title&quot; + (ngModelChange)=&quot;title=$event&quot;, which passes the signal function itself to ngModel and then replaces the signal with a plain string on the first change event, destroying it. Use the split form instead:</p><pre>&lt;input [ngModel]=&quot;title()&quot; (ngModelChange)=&quot;title.set($event)&quot; name=&quot;title&quot; /&gt;</pre><p>Alternatively, use model() (<strong>Angular 17.2+</strong>) which natively supports two-way binding:</p><pre>title = model(&#39;&#39;);<br><br><br>-- in the template<br>&lt;input [(ngModel)]=&quot;title&quot; name=&quot;title&quot; /&gt;</pre><h3>16. Form Submission — ngSubmit</h3><p>FormsModule enhances &lt;form&gt; elements. Bind (ngSubmit) to handle submission without a page reload.</p><p><strong>Child component:</strong></p><pre>import { Component, output } from &#39;@angular/core&#39;;<br>import { FormsModule } from &#39;@angular/forms&#39;;<br>@Component({ imports: [FormsModule], ... })<br>export class CreateUserComponent {<br>  title = &#39;&#39;;<br>  name = &#39;&#39;;<br>  email = &#39;&#39;;<br>  createUser = output&lt;{ title: string; name: string; email: string }&gt;();<br>  onSubmit() {<br>    this.createUser.emit({<br>      title: this.title,<br>      name: this.name,<br>      email: this.email,<br>    });<br>  }<br>}</pre><p><strong>Child template:</strong></p><pre>&lt;form (ngSubmit)=&quot;onSubmit()&quot;&gt;<br>  &lt;input [(ngModel)]=&quot;title&quot; name=&quot;title&quot; /&gt;<br>  &lt;input [(ngModel)]=&quot;name&quot; name=&quot;name&quot; /&gt;<br>  &lt;input [(ngModel)]=&quot;email&quot; name=&quot;email&quot; /&gt;<br>  &lt;button type=&quot;submit&quot;&gt;Create&lt;/button&gt;<br>&lt;/form&gt;</pre><p><strong>Parent template:</strong></p><pre>&lt;app-create-user (createUser)=&quot;onCreate($event)&quot; /&gt;</pre><h3>17. Content Projection — &lt;ng-content&gt;</h3><p>Similar to children in React. Place &lt;ng-content /&gt; in a child component&#39;s template as a slot; whatever is placed between the child&#39;s opening and closing tags in the parent gets projected into that slot.</p><p><strong>Card component template:</strong></p><pre>&lt;div class=&quot;card&quot;&gt;<br>  &lt;h2&gt;Card Title&lt;/h2&gt;<br>  &lt;ng-content /&gt;<br>&lt;/div&gt;</pre><p><strong>Parent template:</strong></p><pre>&lt;app-card&gt;<br>  &lt;p&gt;This paragraph is projected into the card.&lt;/p&gt;<br>&lt;/app-card&gt;</pre><p><strong>Multiple named slots</strong> — use the select attribute to target specific elements by CSS selector:</p><pre>&lt;div class=&quot;card&quot;&gt;<br>  &lt;div class=&quot;card-header&quot;&gt;<br>    &lt;ng-content select=&quot;[card-header]&quot; /&gt;<br>  &lt;/div&gt;<br>  &lt;div class=&quot;card-body&quot;&gt;<br>    &lt;ng-content select=&quot;[card-body]&quot; /&gt;<br>  &lt;/div&gt;<br>&lt;/div&gt;<br><br><br>&lt;app-card&gt;<br>  &lt;h2 card-header&gt;My Title&lt;/h2&gt;<br>  &lt;p card-body&gt;My content goes here.&lt;/p&gt;<br>&lt;/app-card&gt;</pre><h3>18. Services &amp; Dependency Injection</h3><p>A service decorated with @Injectable({ providedIn: &#39;root&#39; }) is instantiated once and shared across the entire app (singleton). Angular&#39;s DI system injects the same instance wherever it is requested.</p><p><strong>Service:</strong></p><pre>import { Injectable } from &#39;@angular/core&#39;;<br>@Injectable({ providedIn: &#39;root&#39; })<br>export class TasksService {<br>  private tasks = [&#39;Task 1&#39;, &#39;Task 2&#39;];<br>  getTasks() {<br>    return this.tasks;<br>  }<br>}</pre><p><strong>Constructor injection</strong> (traditional style):</p><pre>export class TasksComponent {<br>  constructor(private taskService: TasksService) {}<br><br>  getTasks() {<br>    return this.taskService.getTasks();<br>  }<br>}</pre><p><strong>inject() function</strong> (<strong>Angular 14+</strong>, preferred in modern Angular):</p><pre>import { inject } from &#39;@angular/core&#39;;<br><br>export class TasksComponent {<br>  private taskService = inject(TasksService);<br><br>  getTasks() {<br>    return this.taskService.getTasks();<br>  }<br>}</pre><p>inject() is preferred in modern code because it works in field initializers (no constructor needed), plays well with signals, and can be used in standalone functions (e.g. route guards, interceptors) where a constructor is not available.</p><p><strong>Component-scoped service</strong> — provide a service in the component’s providers array to get a fresh instance per component (not a singleton):</p><pre>@Component({<br>  providers: [TasksService],<br>  ...<br>})<br>export class TasksComponent { ... }</pre><p>To be continued…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=951e07a6e505" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Form handling options with React, React Router 7, Next.js]]></title>
            <link>https://medium.com/@atillabaspinar/form-handling-with-react-react-router-7-or-next-js-1f2205fba646?source=rss-cd2bdb7a529b------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f2205fba646</guid>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[form-handling-in-react]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-router-v7]]></category>
            <dc:creator><![CDATA[atilla baspinar]]></dc:creator>
            <pubDate>Mon, 04 May 2026 14:25:18 GMT</pubDate>
            <atom:updated>2026-06-01T16:49:26.350Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Form handling in modern React stacks is spread across many APIs: classic submit handlers, React 19 actions and hooks, React Router 7 route actions and framework loaders, Next.js Server Actions, and more. The surface area is large, and the options <strong>overlap in purpose</strong> — pending UI, validation, navigation after success, and where code runs (client vs server) show up again and again under different names.</p><p>Because it is easy to lose the forest for the trees, this guide <strong>draws one outline of the whole landscape</strong>: each approach is placed in context, with a short concept, the hooks or route APIs involved, and concrete examples. A fact-check section at the end calls out common misconceptions so you can compare claims to how things actually behave.</p><p><strong>What you will find below:</strong> React classic vs React 19 actions vs React Router 7 framework (full-stack) vs RR7 route-action forms vs Next.js Server Actions — concepts, fact-checks, and minimal examples.</p><h3>1) React classic (onSubmit)</h3><h3>Concept</h3><p>Handle submit in JS. Without <strong>preventDefault()</strong>, the browser performs a <strong>full navigation</strong> (native form submit). You read fields via <strong>FormData</strong> or controlled inputs, then <strong>fetch</strong>, set state, etc.</p><h3>Hooks / APIs</h3><ul><li>No required hooks; often useState for errors/loading.</li><li><strong>Navigate after success:</strong> use your stack’s router (react-router useNavigate, Next useRouter().push, etc.) — not built into React.</li></ul><h3>Notes</h3><ul><li><strong>async </strong><strong>onSubmit:</strong> allowed; <strong>preventDefault()</strong> must run <strong>before</strong> the first await.</li><li>Navigate <strong>after</strong> async work succeeds; on failure, stay and show errors.</li></ul><h3>Example</h3><pre>import { useState, type FormEvent } from &quot;react&quot;;<br>import { useNavigate } from &quot;react-router&quot;; // or next/navigation, etc.<br><br>export function ClassicForm() {<br>  const [error, setError] = useState&lt;string | null&gt;(null);<br>  const navigate = useNavigate();<br><br>  async function onSubmit(e: FormEvent&lt;HTMLFormElement&gt;) {<br>    e.preventDefault(); // synchronous - before await<br>    setError(null);<br>    const fd = new FormData(e.currentTarget);<br>    const email = String(fd.get(&quot;email&quot;) ?? &quot;&quot;);<br>    const res = await fetch(&quot;/api/signup&quot;, {<br>      method: &quot;POST&quot;,<br>      headers: { &quot;content-type&quot;: &quot;application/json&quot; },<br>      body: JSON.stringify({ email }),<br>    });<br>    if (!res.ok) {<br>      setError(&quot;Signup failed&quot;);<br>      return;<br>    }<br>    navigate(&quot;/thanks&quot;);<br>  }<br><br>  return (<br>    &lt;form onSubmit={onSubmit}&gt;<br>      &lt;input name=&quot;email&quot; /&gt;<br>      &lt;button type=&quot;submit&quot;&gt;Submit&lt;/button&gt;<br>      {error &amp;&amp; &lt;p&gt;{error}&lt;/p&gt;}<br>    &lt;/form&gt;<br>  );<br>}</pre><h3>2) React 19 — client “Actions” (&lt;form action={fn}&gt;, useActionState, useFormStatus)</h3><h3>Concept</h3><p>React wires <strong>&lt;form&gt;</strong> to a <strong>function</strong> that receives <strong>FormData</strong>. Pending/submit wiring is ergonomic on the client; navigation is still <strong>your</strong> responsibility unless a framework handles it (e.g. server redirect).</p><h3>Hooks / APIs</h3><ul><li><strong>useActionState(action, initialState)</strong> → [state, formAction, isPending]</li><li>action(previousState, formData) when driven by a form.</li><li><strong>useFormStatus()</strong> from <strong>react-dom</strong> → { pending, data, method, action }</li><li>Must be used from a component rendered <strong>inside</strong> the &lt;form&gt; (e.g. a child &lt;SubmitButton /&gt;). Follow the <a href="https://react.dev/reference/react-dom/hooks/useFormStatus">React </a><a href="https://react.dev/reference/react-dom/hooks/useFormStatus">useFormStatus</a> pattern.</li></ul><h3>Example A — plain function action + useFormStatus</h3><pre>&quot;use client&quot;;<br>import { useFormStatus } from &quot;react-dom&quot;;<br><br>async function createUser(formData: FormData) {<br>  const email = String(formData.get(&quot;email&quot;) ?? &quot;&quot;);<br>  await fetch(&quot;/api/signup&quot;, {<br>    method: &quot;POST&quot;,<br>    headers: { &quot;content-type&quot;: &quot;application/json&quot; },<br>    body: JSON.stringify({ email }),<br>  });<br>}<br><br>function SubmitButton() {<br>  const { pending } = useFormStatus();<br>  return &lt;button disabled={pending}&gt;{pending ? &quot;Saving…&quot; : &quot;Save&quot;}&lt;/button&gt;;<br>}<br><br>export function ActionForm() {<br>  return (<br>    &lt;form action={createUser}&gt;<br>      &lt;input name=&quot;email&quot; /&gt;<br>      &lt;SubmitButton /&gt;<br>    &lt;/form&gt;<br>  );<br>}</pre><h3>Example B — useActionState + navigate after success</h3><pre>&quot;use client&quot;;<br>import { useActionState } from &quot;react&quot;;<br>import { useNavigate } from &quot;react-router&quot;;<br><br>export function StatefulActionForm() {<br>  const navigate = useNavigate();<br>  const [error, formAction, isPending] = useActionState(<br>    async (_prev: string | null, formData: FormData) =&gt; {<br>      const email = String(formData.get(&quot;email&quot;) ?? &quot;&quot;);<br>      if (!email.includes(&quot;@&quot;)) return &quot;Invalid email&quot;;<br>      const res = await fetch(&quot;/api/signup&quot;, {<br>        method: &quot;POST&quot;,<br>        headers: { &quot;content-type&quot;: &quot;application/json&quot; },<br>        body: JSON.stringify({ email }),<br>      });<br>      if (!res.ok) return &quot;Server rejected signup&quot;;<br>      navigate(&quot;/thanks&quot;);<br>      return null;<br>    },<br>    null<br>  );<br>  return (<br>    &lt;form action={formAction}&gt;<br>      &lt;input name=&quot;email&quot; /&gt;<br>      &lt;button disabled={isPending}&gt;Submit&lt;/button&gt;<br>      {error &amp;&amp; &lt;p&gt;{error}&lt;/p&gt;}<br>    &lt;/form&gt;<br>  );<br>}</pre><h3>3) React Router 7 — route action + &lt;Form&gt; / useSubmit / useFetcher</h3><h3>Concept</h3><p><strong>HTTP + routing:</strong> &lt;Form method=&quot;post&quot;&gt; submits to a URL; the matched route’s <strong>export async function action({ request, params, ... })</strong> runs. Read body with <strong>await request.formData()</strong> (when appropriate). Return JSON for <strong>useActionData</strong>, or <strong>redirect()</strong>. RR <strong>revalidates</strong> loaders after mutations.</p><h3>Hooks / APIs (roles)</h3><p><strong>API:</strong> action({ request, params, ... })<br><strong>Role:</strong> Mutation handler for the route.</p><p><strong>API:</strong> &lt;Form method=&quot;post&quot;&gt;<br><strong>Role:</strong> Declarative submit; optional action URL (defaults to <strong>current route</strong>).</p><p><strong>API:</strong> useActionData()<br><strong>Role:</strong> Data returned by the <strong>last navigation’s</strong> action for <strong>this</strong> route (not fetcher submissions).</p><p><strong>API:</strong> useNavigation()<br><strong>Role:</strong> Pending navigation, formMethod, formAction, state (submitting / loading / idle), etc.</p><p><strong>API:</strong> useSubmit()<br><strong>Role:</strong> Imperative submit(formOrData, { method, action, encType }).</p><p><strong>API:</strong> useFetcher()<br><strong>Role:</strong> Submit/load <strong>without</strong> changing the history URL; use fetcher.Form, fetcher.submit, read fetcher.data / fetcher.state.</p><h3>Example — action, &lt;Form&gt;, useActionData, useNavigation</h3><pre>import { Form, redirect, useActionData, useNavigation } from &quot;react-router&quot;;<br>import type { Route } from &quot;./+types/signup&quot;; // shape depends on RR template<br><br>export async function action({ request }: Route.ActionArgs) {<br>  const formData = await request.formData();<br>  const email = String(formData.get(&quot;email&quot;) ?? &quot;&quot;);<br>  if (!email.includes(&quot;@&quot;)) {<br>    return { ok: false as const, error: &quot;Invalid email&quot; };<br>  }<br>  // await db...<br>  return redirect(&quot;/thanks&quot;);<br>}<br><br>export default function Signup() {<br>  const actionData = useActionData() as { ok: false; error: string } | undefined;<br>  const navigation = useNavigation();<br>  const busy =<br>    navigation.state === &quot;submitting&quot; &amp;&amp;<br>    navigation.formMethod?.toLowerCase() === &quot;post&quot;;<br>  return (<br>    &lt;Form method=&quot;post&quot;&gt;<br>      &lt;input name=&quot;email&quot; /&gt;<br>      &lt;button disabled={busy}&gt;Submit&lt;/button&gt;<br>      {actionData?.ok === false &amp;&amp; &lt;p&gt;{actionData.error}&lt;/p&gt;}<br>    &lt;/Form&gt;<br>  );<br>}</pre><h3>useSubmit (imperative)</h3><pre>import { useSubmit } from &quot;react-router&quot;;<br><br>export function ImperativeSave() {<br>  const submit = useSubmit();<br>  return (<br>    &lt;button<br>      type=&quot;button&quot;<br>      onClick={() =&gt; {<br>        const fd = new FormData();<br>        fd.set(&quot;email&quot;, &quot;a@b.com&quot;);<br>        submit(fd, { method: &quot;post&quot; }); // action URL optional - defaults like &lt;Form&gt;<br>      }}<br>    &gt;<br>      Save<br>    &lt;/button&gt;<br>  );<br>}</pre><h3>useFetcher (no history navigation)</h3><pre>import { useFetcher } from &quot;react-router&quot;;<br><br>export function InlineLike() {<br>  const fetcher = useFetcher();<br>  return (<br>    &lt;fetcher.Form method=&quot;post&quot; action=&quot;/signup&quot;&gt;<br>      &lt;input name=&quot;email&quot; /&gt;<br>      &lt;button disabled={fetcher.state !== &quot;idle&quot;}&gt;Save&lt;/button&gt;<br>      {fetcher.data &amp;&amp; typeof fetcher.data === &quot;object&quot; &amp;&amp; &quot;error&quot; in fetcher.data &amp;&amp; (<br>        &lt;p&gt;{String((fetcher.data as { error: unknown }).error)}&lt;/p&gt;<br>      )}<br>    &lt;/fetcher.Form&gt;<br>  );<br>}</pre><p>Omit <strong>action</strong> on fetcher.Form when targeting the <strong>current</strong> route’s action.</p><h3>4) React Router 7 — Framework mode (full-stack route modules)</h3><h3>Concept</h3><p>In <strong>framework</strong> apps (e.g. @react-router/dev + Vite, “Remix-style” SSR), each route file is a <strong>module</strong> that can export <strong>loader</strong>, <strong>action</strong>, and related pieces. <strong>GET</strong> navigations run <strong>loader</strong> (read DB, auth, shape props). <strong>POST</strong> from <strong>&lt;Form method=&quot;post&quot;&gt;</strong> (or useSubmit / useFetcher) runs <strong>action</strong> on the <strong>server</strong> for document requests and through RR’s <strong>data API</strong> on client navigations—often with <strong>single-fetch</strong> behavior in v7. After a successful mutation, matching <strong>loaders revalidate</strong> unless you opt out with <strong>shouldRevalidate</strong>. Use <strong>redirect()</strong> / <strong>data()</strong> from <strong>react-router</strong> for typed HTTP-style returns.</p><h3>Hooks / APIs (framework + data layer)</h3><p><strong>API:</strong> loader({ request, params, context })<br><strong>Role:</strong> Supply read-model data for the route (and parents); runs before render on navigations.</p><p><strong>API:</strong> action({ request, params, context })<br><strong>Role:</strong> Mutations; same args shape as loader; read request.formData() / request.json() as needed.</p><p><strong>API:</strong> clientLoader<strong> / </strong>clientAction<br><strong>Role:</strong> Optional <strong>client</strong> handlers on navigations/submits. When a server loader<strong> / </strong>action exists too, args expose serverLoader() / serverAction() so you can run client work, then <strong>delegate</strong> (or skip) the server call.</p><p><strong>API:</strong> shouldRevalidate<br><strong>Role:</strong> Control whether loaders re-run after an action (default: revalidate).</p><p><strong>API:</strong> useLoaderData()<br><strong>Role:</strong> Read the <strong>current route’s</strong> loader result (typed via ./+types/&lt;route&gt; in generated setups).</p><p><strong>API:</strong> useRouteLoaderData(routeId)<br><strong>Role:</strong> Read a <strong>parent</strong> (or named) route’s loader data—common for layout auth or shared config.</p><p><strong>API:</strong> useActionData()<br><strong>Role:</strong> Last <strong>navigation</strong> action return for <strong>this</strong> route (not useFetcher by default—use fetcher.data there).</p><p><strong>API:</strong> useNavigation()<br><strong>Role:</strong> Pending transition: state, formMethod, formAction, location, etc.</p><p><strong>API:</strong> useRevalidator()<br><strong>Role:</strong> Imperative revalidate() when you need a loader refresh without a form post.</p><p><strong>API:</strong> useFetcher()<br><strong>Role:</strong> POST/GET <strong>without</strong> a new history entry; fetcher.Form, fetcher.load, fetcher.state, fetcher.data.</p><p><strong>API:</strong> useRouteError() + route ErrorBoundary<br><strong>Role:</strong> Surface throw data() / Response errors from loaders/actions.</p><p><strong>API:</strong> Form, Link (prefetch)<br><strong>Role:</strong> Declarative navigation and mutation; redirect from server action completes the flow.</p><h3>Example — loader + action + &lt;Form&gt; (one route module)</h3><pre>import { data, Form, redirect, useActionData, useLoaderData, useNavigation } from &quot;react-router&quot;;<br>import type { Route } from &quot;./+types/signup&quot;; // shape depends on RR template<br><br>export async function loader(_args: Route.LoaderArgs) {<br>  // e.g. read session, defaults - return JSON-safe payload<br>  return data({ defaultEmail: &quot;&quot; });<br>}<br><br>export async function action({ request }: Route.ActionArgs) {<br>  const formData = await request.formData();<br>  const email = String(formData.get(&quot;email&quot;) ?? &quot;&quot;);<br>  if (!email.includes(&quot;@&quot;)) {<br>    return data({ ok: false as const, error: &quot;Invalid email&quot; }, { status: 400 });<br>  }<br>  // await db...<br>  return redirect(&quot;/thanks&quot;);<br>}<br><br>export default function Signup() {<br>  const { defaultEmail } = useLoaderData() as { defaultEmail: string };<br>  const actionData = useActionData() as { ok: false; error: string } | undefined;<br>  const navigation = useNavigation();<br>  const busy =<br>    navigation.state === &quot;submitting&quot; &amp;&amp;<br>    navigation.formMethod?.toLowerCase() === &quot;post&quot;;<br>  return (<br>    &lt;Form method=&quot;post&quot;&gt;<br>      &lt;input name=&quot;email&quot; defaultValue={defaultEmail} /&gt;<br>      &lt;button disabled={busy}&gt;Submit&lt;/button&gt;<br>      {actionData?.ok === false &amp;&amp; &lt;p&gt;{actionData.error}&lt;/p&gt;}<br>    &lt;/Form&gt;<br>  );<br>}</pre><h3>Example — clientAction + server action (same route module / component file)</h3><p>On <strong>client-driven</strong> submits (typical SPA navigation), if you export <strong>clientAction</strong>, it runs <strong>in the browser</strong> and <strong>replaces</strong> the default client call to your server <strong>action</strong>—unless you call <strong>serverAction()</strong> inside it, which runs the server <strong>action</strong> and returns its result (same shape <strong>useActionData</strong> sees).</p><p>Use this to merge <strong>browser-only</strong> work (clear a cache, read <strong>sessionStorage</strong>, attach telemetry) with <strong>server persistence</strong> in one route file alongside the default export component.</p><pre>import { data, Form, redirect, useActionData, useLoaderData, useNavigation } from &quot;react-router&quot;;<br>import type { Route } from &quot;./+types/signup&quot;;<br><br>export async function loader(_args: Route.LoaderArgs) {<br>  return data({ defaultEmail: &quot;&quot; });<br>}<br><br>/** Runs on the server (and when `serverAction()` is invoked from `clientAction`). */<br>export async function action({ request }: Route.ActionArgs) {<br>  const formData = await request.formData();<br>  const email = String(formData.get(&quot;email&quot;) ?? &quot;&quot;);<br>  if (!email.includes(&quot;@&quot;)) {<br>    return data({ ok: false as const, error: &quot;Invalid email&quot; }, { status: 400 });<br>  }<br>  // await db...<br>  return redirect(&quot;/thanks&quot;);<br>}<br><br>/** Runs on the client when the user posts via `&lt;Form&gt;` / `useSubmit` on a client transition. */<br>export async function clientAction({ request, serverAction }: Route.ClientActionArgs) {<br>  // Client-only side effects before hitting the server action:<br>  sessionStorage.removeItem(&quot;signup-draft&quot;);<br>  // Peek at fields on a clone so the original `request` body is still readable by `serverAction()`.<br>  const fd = await request.clone().formData();<br>  if (fd.get(&quot;intent&quot;) === &quot;preview&quot;) {<br>    return data({ ok: true as const, mode: &quot;preview&quot; as const, email: String(fd.get(&quot;email&quot;) ?? &quot;&quot;) });<br>  }<br>  return serverAction();<br>}<br><br><br>export default function Signup() {<br>  const { defaultEmail } = useLoaderData() as { defaultEmail: string };<br>  const actionData = useActionData() as<br>    | { ok: false; error: string }<br>    | { ok: true; mode: &quot;preview&quot;; email: string }<br>    | undefined;<br>  const navigation = useNavigation();<br>  const busy =<br>    navigation.state === &quot;submitting&quot; &amp;&amp;<br>    navigation.formMethod?.toLowerCase() === &quot;post&quot;;<br>  return (<br>    &lt;Form method=&quot;post&quot;&gt;<br>      &lt;input name=&quot;email&quot; defaultValue={defaultEmail} /&gt;<br>      &lt;button type=&quot;submit&quot; name=&quot;intent&quot; value=&quot;save&quot; disabled={busy}&gt;<br>        Save<br>      &lt;/button&gt;<br>      &lt;button type=&quot;submit&quot; name=&quot;intent&quot; value=&quot;preview&quot; disabled={busy}&gt;<br>        Preview (client branch)<br>      &lt;/button&gt;<br>      {actionData?.ok === false &amp;&amp; &lt;p&gt;{actionData.error}&lt;/p&gt;}<br>      {actionData?.ok === true &amp;&amp; actionData.mode === &quot;preview&quot; &amp;&amp; (<br>        &lt;p&gt;Preview: {actionData.email}&lt;/p&gt;<br>      )}<br>    &lt;/Form&gt;<br>  );<br>}</pre><p><strong>Caveats:</strong> Reading <strong>request.formData()</strong> (or <strong>json()</strong>) consumes the body. If you still need <strong>serverAction()</strong> afterward, <strong>await request.clone().formData()</strong> for inspection branches, then call <strong>serverAction()</strong> on the original <strong>request</strong>. Alternatively, handle the branch entirely on the client without calling <strong>serverAction()</strong>. <strong>serverAction()</strong> exists only when a server <strong>action</strong> is exported; <strong>full document</strong> posts still invoke the server <strong>action</strong> directly.</p><p><strong>Note:</strong> The same <strong>action / </strong><strong>&lt;Form&gt; / </strong><strong>useFetcher</strong> mechanics apply in framework mode; section 4 focuses on those building blocks and imperative patterns.</p><h3>5) Next.js App Router — Server Actions + same React hooks</h3><h3>Concept</h3><p>&quot;use server&quot; marks <strong>server-only</strong> functions. &lt;form action={serverAction}&gt; uses Next’s <strong>Server Action</strong> transport (not RR’s route action).</p><h3>Rules / gotchas</h3><ul><li>Define exported actions in a <strong>&#39;use server&#39;</strong> file and <strong>import</strong> into Client Components.</li><li><strong>useFormStatus:</strong> import { useFormStatus } from &quot;react-dom&quot;.</li><li><strong>useActionState:</strong> import { useActionState } from &quot;react&quot; — pair with server actions for inline errors / returned state; use <strong>redirect()</strong> from <strong>next/navigation</strong> for success navigation when appropriate.</li></ul><h3>Example — Server Action + useFormStatus</h3><pre>// app/actions.ts<br>&quot;use server&quot;;<br><br>import { redirect } from &quot;next/navigation&quot;;<br>export async function signup(formData: FormData) {<br>  const email = String(formData.get(&quot;email&quot;) ?? &quot;&quot;);<br>  if (!email.includes(&quot;@&quot;)) return; // could return state instead - see below<br>  // await db...<br>  redirect(&quot;/thanks&quot;);<br>}</pre><pre>// app/signup-form.tsx<br>&quot;use client&quot;;<br><br>import { useFormStatus } from &quot;react-dom&quot;;<br>import { signup } from &quot;./actions&quot;;<br><br>function SubmitButton() {<br>  const { pending } = useFormStatus();<br>  return &lt;button disabled={pending}&gt;{pending ? &quot;Saving…&quot; : &quot;Save&quot;}&lt;/button&gt;;<br>}<br><br>export function SignupForm() {<br>  return (<br>    &lt;form action={signup}&gt;<br>      &lt;input name=&quot;email&quot; /&gt;<br>      &lt;SubmitButton /&gt;<br>    &lt;/form&gt;<br>  );<br>}</pre><h3>Example — useActionState + Server Action (return state on validation error)</h3><pre>// app/actions.ts<br>&quot;use server&quot;;<br><br>export type SignupState = { error: string | null };<br>export async function signupWithState(<br>  _prev: SignupState,<br>  formData: FormData<br>): Promise&lt;SignupState&gt; {<br>  const email = String(formData.get(&quot;email&quot;) ?? &quot;&quot;);<br>  if (!email.includes(&quot;@&quot;)) return { error: &quot;Invalid email&quot; };<br>  // await db...<br>  return { error: null };<br>}</pre><pre>// app/signup-form-state.tsx<br>&quot;use client&quot;;<br><br>import { useActionState } from &quot;react&quot;;<br>import { signupWithState, type SignupState } from &quot;./actions&quot;;<br>export function SignupFormWithState() {<br>  const [state, formAction, pending] = useActionState(signupWithState, {<br>    error: null,<br>  } satisfies SignupState);<br>  return (<br>    &lt;form action={formAction}&gt;<br>      &lt;input name=&quot;email&quot; /&gt;<br>      &lt;button disabled={pending}&gt;Save&lt;/button&gt;<br>      {state.error &amp;&amp; &lt;p&gt;{state.error}&lt;/p&gt;}<br>    &lt;/form&gt;<br>  );<br>}</pre><p><strong>Navigation after success:</strong> redirect() inside the server action, or return state and navigate on the client — pick one strategy per flow so you do not redirect away while still trying to show inline errors.</p><h3>One-line “when do I pick what?”</h3><ul><li><strong>Classic </strong><strong>onSubmit:</strong> full manual control; you own validation, requests, and pending UI.</li><li><strong>React 19 actions / hooks:</strong> React-managed submit + pending patterns on the <strong>client</strong>; compose with any router for navigation.</li><li><strong>RR7 framework (full-stack):</strong> route <strong>loader + </strong><strong>action</strong> modules, SSR/data protocol, <strong>revalidation</strong>, <strong>useLoaderData</strong>, optional <strong>clientLoader / </strong><strong>clientAction</strong>, <strong>shouldRevalidate</strong>, <strong>data() / </strong><strong>redirect()</strong>—forms are one part of the route lifecycle.</li><li><strong>RR7 route-action forms (</strong><strong>&lt;Form&gt;, fetchers):</strong> mutations as <strong>routed POSTs</strong> + <strong>useActionData / </strong><strong>useNavigation / </strong><strong>useSubmit / </strong><strong>useFetcher</strong> without restating the full loader story.</li><li><strong>Next Server Actions:</strong> mutations as <strong>server RPC</strong> from forms; <strong>same</strong> useFormStatus / useActionState from <strong>react-dom</strong> / <strong>react</strong>.</li></ul><h3>Imports cheat sheet</h3><pre>import { useActionState } from &quot;react&quot;;<br>import { useFormStatus } from &quot;react-dom&quot;;</pre><pre>// React Router 7 (framework + forms)<br>import {<br>  data,<br>  Form,<br>  redirect,<br>  useActionData,<br>  useLoaderData,<br>  useNavigation,<br>  useRevalidator,<br>  useRouteLoaderData,<br>  useFetcher,<br>  useSubmit,<br>} from &quot;react-router&quot;;</pre><pre>// Next.js (server action file)<br>&quot;use server&quot;;<br>import { redirect } from &quot;next/navigation&quot;;</pre><h3>Fact-check (quick reference)</h3><p><strong>Claim:</strong> Classic: onSubmit + preventDefault<br><strong>Verdict:</strong> Correct.</p><p><strong>Claim:</strong> Classic handler can be async<br><strong>Verdict:</strong> <strong>Yes</strong>, but call event.preventDefault()<strong> synchronously</strong> (ideally first line) before any await, or the browser may still perform a native submit.</p><p><strong>Claim:</strong> React 19: &lt;form action={…}&gt; receives FormData; action can be async<br><strong>Verdict:</strong> Correct for <strong>function</strong> action props / useActionState dispatch.</p><p><strong>Claim:</strong> useFormStatus ≈ RR useNavigation<br><strong>Verdict:</strong> <strong>Roughly</strong> for “pending submit” only — not equivalent. useFormStatus is <strong>form-scoped</strong> and lives in react-dom; useNavigation is <strong>navigation-scoped</strong> (loaders, location, GET/POST, etc.).</p><p><strong>Claim:</strong> RR7 actions: request, params, await request.formData()<br><strong>Verdict:</strong> Correct for typical <strong>POST</strong> FormData bodies.</p><p><strong>Claim:</strong> RR7 framework: loader + action in the same route module<br><strong>Verdict:</strong> Correct pattern; useLoaderData for reads, &lt;Form method=&quot;post&quot;&gt; for action.</p><p><strong>Claim:</strong> RR7: data() for loader/action return (status + body)<br><strong>Verdict:</strong> data() from react-router is the idiomatic typed helper in v7 (alongside raw Response).</p><p><strong>Claim:</strong> RR7: redirect after action<br><strong>Verdict:</strong> Correct in a <strong>route </strong>action (e.g. import redirect from react-router in v7).</p><p><strong>Claim:</strong> RR7 &lt;Form&gt;: action prop optional<br><strong>Verdict:</strong> <strong>Correct.</strong> Default targets the <strong>current route context</strong> (not DOM “closest”). Use method=&quot;post&quot; to invoke the route action.</p><p><strong>Claim:</strong> useSubmit, useNavigation, useActionData<br><strong>Verdict:</strong> Correct roles (see section 4).</p><p><strong>Claim:</strong> useFetcher always needs action<br><strong>Verdict:</strong> <strong>Correction:</strong> action is <strong>optional</strong> on fetcher.Form / fetcher.submit (defaults like &lt;Form&gt;). Pass action when posting to <strong>another</strong> route/path.</p><p><strong>Claim:</strong> Next: Server Actions + &quot;use server&quot;<br><strong>Verdict:</strong> Correct pattern.</p><p><strong>Claim:</strong> Next: exported server actions should be async<br><strong>Verdict:</strong> <strong>Practical rule:</strong> exported server actions in &#39;use server&#39; files should be async (Next enforces this in common setups).</p><p><strong>Claim:</strong> Server action <strong>defined inside</strong> &quot;use client&quot; file<br><strong>Verdict:</strong> <strong>Invalid</strong> — move to a server file (or valid server boundary); import into client.</p><p><strong>Claim:</strong> Pending UI: useFormStatus; returned state/errors: useActionState<br><strong>Verdict:</strong> Correct. <strong>Imports:</strong> useFormStatus → react-dom, useActionState → react (not next/*).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f2205fba646" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Confusion around CSS Display and Position made easy]]></title>
            <link>https://medium.com/@atillabaspinar/confusion-around-css-display-and-position-made-easy-bfcc07abe210?source=rss-cd2bdb7a529b------2</link>
            <guid isPermaLink="false">https://medium.com/p/bfcc07abe210</guid>
            <category><![CDATA[css-position]]></category>
            <category><![CDATA[css-display]]></category>
            <dc:creator><![CDATA[atilla baspinar]]></dc:creator>
            <pubDate>Sat, 11 Jul 2020 23:08:37 GMT</pubDate>
            <atom:updated>2020-07-12T09:55:49.400Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>CSS Display and Position made easy</strong></h3><p>CSS <strong>display</strong> and <strong>position</strong> properties are often confusing when you are designing the UI of your application. This is because they affect <strong>width, height, top, left, bottom and right</strong> properties differently with each combination of them. It is hard to memorize all the combinations.</p><p>I will not define and describe these properties. This can be easily found on the internet. Instead, I will provide a comparison so that you can get the relation of these properties.</p><p>A visual chart is much better than talking on it for an hour. See the table below, take your time to understand it. Also, check out the codepen link, play with the values in css, if you have time. I believe your confusion will ease if not go for good.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lQynq6FPm83fJgtwpe5H8w.png" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fatillab%2Fembed%2Fpreview%2FYzwvMvm%3Fheight%3D600%26slug-hash%3DYzwvMvm%26default-tabs%3Dhtml%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io&amp;display_name=CodePen&amp;url=https%3A%2F%2Fcodepen.io%2Fatillab%2Fpen%2FYzwvMvm&amp;image=https%3A%2F%2Fassets.codepen.io%2F3341992%2Finternal%2Fscreenshots%2Fpens%2FYzwvMvm.default.png%3Fformat%3Dauto%26amp%3Bha%3Dfalse%26amp%3Bheight%3D360%26amp%3Bquality%3D75%26amp%3Bv%3D1%26amp%3Bversion%3D1594506230%26amp%3Bwidth%3D640&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/8bea664fda46da76c644cf50ee8847d1/href">https://medium.com/media/8bea664fda46da76c644cf50ee8847d1/href</a></iframe><p>When you spend some time looking at the table, you will notice some patterns:</p><p>1- <strong>position: absolute</strong> and <strong>position:fixed</strong> overrides display value and turns it to an “<strong>inline-block</strong>”. This rule overrides the rules below. So, you are free to set height, width, top, or bottom. They are all effective.</p><p>2- <strong>Position</strong> controls <strong>top, left, bottom, right </strong>properties. (Well, this is what position is, no?)<br><strong>position: static</strong>, they are ignored. <br><strong>position: relative</strong>, they are in effect.</p><p>3- <strong>Display</strong> controls <strong>height and width</strong> properties.<br><strong>display: inline</strong>, they are ignored<br><strong>display: block,</strong> they are in effect</p><p>4- When <strong>position:absolute </strong>is set, <strong>display:inline</strong> and <strong>display:block</strong> are not quite the same. It will still put the element in its place (inline) or it will start from the next line (block). But this is almost never noticed since position:absolute comes almost always with top, height etc. properties.</p><p>5- Similar to rule 4, when <strong>position:fixed</strong> is set, <strong>display:inline</strong> and <strong>display:block</strong> are not the same. It will still put the element in its place (inline) or it will start from the next line (block) unless you set position properties. But again, position properties (if set) will modify the position.</p><h3><strong>Conclusion</strong></h3><p>When taken out of flow: Use position:absolute/fixed, then adjust size and position properties.</p><p>When the element should be in flow: <br>If you want to resize, use display: block (or inline-block)<br>If you want to move, use position: relative<br>If you want both, use both!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bfcc07abe210" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>