Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions docs/api/remix.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,15 @@ export default function Signup() {
<Form method="post">
<p>
<input type="text" name="email" />
{errors?.email && <span>{errors.email}</span>}
{errors?.email ? (
<span>{errors.email}</span>
) : null}
</p>
<p>
<input type="text" name="password" />
{errors?.password && (
{errors?.password ? (
<span>{errors.password}</span>
)}
) : null}
</p>
<p>
<button type="submit">Sign up</button>
Expand Down Expand Up @@ -399,9 +401,9 @@ function UserPreferences() {
<input type="checkbox" name="darkMode" value="on" />{" "}
Dark Mode
</label>
{transition.state === "submitting" && (
{transition.state === "submitting" ? (
<p>Saving...</p>
)}
) : null}
</Form>
);
}
Expand Down Expand Up @@ -748,12 +750,13 @@ function NewsletterSignup() {
</button>
</p>

{newsletter.type === "done" &&
(newsletter.data.ok ? (
{newsletter.type === "done" ? (
newsletter.data.ok ? (
<p>Thanks for subscribing!</p>
) : newsletter.data.error ? (
<p data-error>{newsletter.data.error}</p>
) : null)}
) : null
) : null}
</newsletter.Form>
);
}
Expand Down
8 changes: 5 additions & 3 deletions docs/guides/api-routes.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ function CitySearchCombobox() {
cities.submit(event.target.form)
}
/>
{cities.state === "submitting" && <Spinner />}
{cities.state === "submitting" ? (
<Spinner />
) : null}
</div>

{cities.data && (
{cities.data ? (
<ComboboxPopover className="shadow-popup">
{cities.data.error ? (
<p>Failed to load cities :(</p>
Expand All @@ -75,7 +77,7 @@ function CitySearchCombobox() {
<span>No results found</span>
)}
</ComboboxPopover>
)}
) : null}
</Combobox>
</cities.Form>
);
Expand Down
20 changes: 10 additions & 10 deletions docs/guides/data-writes.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,11 @@ export default function NewProject() {
</label>
</p>

{actionData?.errors.name && (
{actionData?.errors.name ? (
<p style={{ color: "red" }}>
{actionData.errors.name}
</p>
)}
) : null}

<p>
<label>
Expand All @@ -265,11 +265,11 @@ export default function NewProject() {
</label>
</p>

{actionData?.errors.description && (
{actionData?.errors.description ? (
<p style={{ color: "red" }}>
{actionData.errors.description}
</p>
)}
) : null}

<p>
<button type="submit">Create</button>
Expand Down Expand Up @@ -346,11 +346,11 @@ export default function NewProject() {
</label>
</p>

{actionData && actionData.errors.name && (
{actionData && actionData.errors.name ? (
<p style={{ color: "red" }}>
{actionData.errors.name}
</p>
)}
) : null}

<p>
<label>
Expand All @@ -367,11 +367,11 @@ export default function NewProject() {
</label>
</p>

{actionData && actionData.errors.description && (
{actionData && actionData.errors.description ? (
<p style={{ color: "red" }}>
{actionData.errors.description}
</p>
)}
) : null}

<p>
<button type="submit">
Expand Down Expand Up @@ -453,12 +453,12 @@ export default function NewProject() {
</label>
</p>

{actionData?.errors.name && (
{actionData?.errors.name ? (
<ValidationMessage
isSubmitting={transition.state === "submitting"}
error={actionData?.errors?.name}
/>
)}
) : null}

<p>
<label>
Expand Down
4 changes: 3 additions & 1 deletion docs/guides/mdx.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ export default function Index() {
{posts.map(post => (
<li key={post.slug}>
<Link to={post.slug}>{post.title}</Link>
{post.description && <p>{post.description}</p>}
{post.description ? (
<p>{post.description}</p>
) : null}
</li>
))}
</ul>
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/optimistic-ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export default function NewProject() {
<textarea name="description" id="description" />
<button type="submit">Create Project</button>
</Form>
{error && <p>{error}</p>}
{error ? <p>{error}</p> : null}
</>
);
}
Expand Down
10 changes: 7 additions & 3 deletions docs/tutorials/blog.md
Original file line number Diff line number Diff line change
Expand Up @@ -873,20 +873,24 @@ export default function NewPost() {
<p>
<label>
Post Title:{" "}
{errors?.title && <em>Title is required</em>}
{errors?.title ? (
<em>Title is required</em>
) : null}
<input type="text" name="title" />
</label>
</p>
<p>
<label>
Post Slug:{" "}
{errors?.slug && <em>Slug is required</em>}
{errors?.slug ? <em>Slug is required</em> : null}
<input type="text" name="slug" />
</label>
</p>
<p>
<label htmlFor="markdown">Markdown:</label>{" "}
{errors?.markdown && <em>Markdown is required</em>}
{errors?.markdown ? (
<em>Markdown is required</em>
) : null}
<br />
<textarea rows={20} name="markdown" />
</p>
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function Document({
<RouteChangeAnnouncement />
<ScrollRestoration />
<Scripts />
{process.env.NODE_ENV === "development" && <LiveReload />}
{process.env.NODE_ENV === "development" ? <LiveReload /> : null}
</body>
</html>
);
Expand Down
2 changes: 1 addition & 1 deletion examples/blog-tutorial/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function Document({
{children}
<ScrollRestoration />
<Scripts />
{process.env.NODE_ENV === "development" && <LiveReload />}
{process.env.NODE_ENV === "development" ? <LiveReload /> : null}
</body>
</html>
);
Expand Down
11 changes: 6 additions & 5 deletions examples/blog-tutorial/app/routes/admin/new.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { useTransition, useActionData, Form, redirect } from "remix";
import type { ActionFunction } from "remix";
import { createPost } from "~/post";
import invariant from "tiny-invariant";

import { createPost } from "~/post";

export let action: ActionFunction = async ({ request }) => {
await new Promise((res) => setTimeout(res, 1000));
await new Promise(res => setTimeout(res, 1000));
let formData = await request.formData();
let title = formData.get("title");
let slug = formData.get("slug");
Expand Down Expand Up @@ -35,19 +36,19 @@ export default function NewPost() {
<Form method="post">
<p>
<label>
Post Title: {errors?.title && <em>Title is required</em>}
Post Title: {errors?.title ? <em>Title is required</em> : null}
<input type="text" name="title" />
</label>
</p>
<p>
<label>
Post Slug: {errors?.slug && <em>Slug is required</em>}
Post Slug: {errors?.slug ? <em>Slug is required</em> : null}
<input type="text" name="slug" />
</label>
</p>
<p>
<label htmlFor="markdown">Markdown:</label>{" "}
{errors?.markdown && <em>Markdown is required</em>}
{errors?.markdown ? <em>Markdown is required</em> : null}
<br />
<textarea rows={20} name="markdown" />
</p>
Expand Down
2 changes: 1 addition & 1 deletion examples/jokes/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function Document({
<body>
{children}
<Scripts />
{process.env.NODE_ENV === "development" && <LiveReload />}
{process.env.NODE_ENV === "development" ? <LiveReload /> : null}
</body>
</html>
);
Expand Down
4 changes: 2 additions & 2 deletions fixtures/gists-app/app/root.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ export default function Root() {
<div data-test-id="content" id="content">
<Outlet />
</div>
{data.enableScripts && (
{data.enableScripts ? (
<>
<ScrollRestoration />
<Scripts />
</>
)}
) : null}
</body>
</html>
);
Expand Down
2 changes: 1 addition & 1 deletion fixtures/gists-app/app/routes/blog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default function BlogPosts() {
{posts.map(post => (
<li key={post.slug}>
<Link to={post.slug} className="text-blue-700 underline">
{post.title} {locationPending && "..."}
{post.title} {locationPending ? "..." : null}
</Link>
</li>
))}
Expand Down
12 changes: 6 additions & 6 deletions fixtures/gists-app/app/routes/fetchers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ export default function Tasks() {

<hr />
<h2>Tasks</h2>
{searchParams.has("q") && (
{searchParams.has("q") ? (
<p>
Filtered by search: <i>{searchParams.get("q")}</i>
</p>
)}
) : null}

{tasks.map(task => (
<TaskItem key={task.id} task={task} />
Expand Down Expand Up @@ -154,14 +154,14 @@ function TaskItem({ task }: { task: Task }) {
}
>
{renderedTask.complete ? "Mark Incomplete" : "Mark Complete"}
{toggleComplete.state === "submitting" && (
{toggleComplete.state === "submitting" ? (
<ProgressBar key={toggleComplete.submission.key} total={task.delay} />
)}
) : null}
</button>{" "}
{task.name}{" "}
{toggleComplete.type === "done" && "error" in toggleComplete.data && (
{toggleComplete.type === "done" && "error" in toggleComplete.data ? (
<span style={{ color: "red" }}>Error! {toggleComplete.data.error}</span>
)}
) : null}
</toggleComplete.Form>
);
}
Expand Down
2 changes: 1 addition & 1 deletion fixtures/gists-app/app/routes/gists.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function Gists() {
to={user.id}
className="text-blue-700 underline"
>
{user.name} {locationPending && "..."}
{user.name} {locationPending ? "..." : null}
</Link>
</li>
))}
Expand Down
2 changes: 1 addition & 1 deletion packages/create-remix/templates/_shared_js/app/root.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function Document({ children, title }) {
{children}
<ScrollRestoration />
<Scripts />
{process.env.NODE_ENV === "development" && <LiveReload />}
{process.env.NODE_ENV === "development" ? <LiveReload /> : null}
</body>
</html>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/create-remix/templates/_shared_ts/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function Document({
{children}
<ScrollRestoration />
<Scripts />
{process.env.NODE_ENV === "development" && <LiveReload />}
{process.env.NODE_ENV === "development" ? <LiveReload /> : null}
</body>
</html>
);
Expand Down
4 changes: 2 additions & 2 deletions packages/remix-react/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ export let NavLink = React.forwardRef<HTMLAnchorElement, RemixNavLinkProps>(
{...prefetchHandlers}
{...props}
/>
{shouldPrefetch && <PrefetchPageLinks page={href} />}
{shouldPrefetch ? <PrefetchPageLinks page={href} /> : null}
</>
);
}
Expand All @@ -472,7 +472,7 @@ export let Link = React.forwardRef<HTMLAnchorElement, RemixLinkProps>(
{...prefetchHandlers}
{...props}
/>
{shouldPrefetch && <PrefetchPageLinks page={href} />}
{shouldPrefetch ? <PrefetchPageLinks page={href} /> : null}
</>
);
}
Expand Down