Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(website/remix-guide): sample code update #8334

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 28 additions & 14 deletions website/content/getting-started/remix-guide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ We鈥檒l create a `context.tsx` in the `app` folder.

```jsx live=false
// context.tsx
import React, { createContext } from 'react'
import { createContext } from 'react'

export interface ServerStyleContextData {
key: string
Expand Down Expand Up @@ -66,7 +66,7 @@ client and the server. We'll use our createEmotionCache function here.
```jsx live=false
// entry.client.tsx
import React, { useState } from 'react'
import { hydrate } from 'react-dom'
import * as ReactDOM from 'react-dom/client'
import { CacheProvider } from '@emotion/react'
import { RemixBrowser } from '@remix-run/react'

Expand All @@ -91,12 +91,24 @@ function ClientCacheProvider({ children }: ClientCacheProviderProps) {
)
}

hydrate(
<ClientCacheProvider>
<RemixBrowser />
</ClientCacheProvider>,
document,
)
const hydrate = () => {
React.startTransition(() => {
ReactDOM.hydrateRoot(
document,
<ClientCacheProvider>
<RemixBrowser />
</ClientCacheProvider>
);
});
};

if (window.requestIdleCallback) {
window.requestIdleCallback(hydrate)
} else {
// Safari doesn't support requestIdleCallback
// https://caniuse.com/requestidlecallback
setTimeout(hydrate, 1)
}
```

```jsx live=false
Expand Down Expand Up @@ -166,13 +178,15 @@ import { MetaFunction, LinksFunction } from '@remix-run/node' // Depends on the

import { ServerStyleContext, ClientStyleContext } from './context'

export const meta: MetaFunction = () => ({
charset: 'utf-8',
title: 'New Remix App',
viewport: 'width=device-width,initial-scale=1',
});
export const meta: MetaFunction = () => {
return [
{ charSet: 'utf-8' },
{ title: 'New Remix App' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
];
};

export let links: LinksFunction = () => {
export const links: LinksFunction = () => {
return [
{ rel: 'preconnect', href: 'https://fonts.googleapis.com' },
{ rel: 'preconnect', href: 'https://fonts.gstatic.com' },
Expand Down