Skip to content

Commit 8d47abe

Browse files
authored
Merge pull request #65 from reactjs/sync-2372ecf9
Sync with react.dev @ 2372ecf
2 parents 12c4fd5 + fd77750 commit 8d47abe

27 files changed

+1866
-9
lines changed

.github/ISSUE_TEMPLATE/0-bug.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: "🐛 Report a bug"
2+
description: "Report a problem on the website."
3+
title: "[Bug]: "
4+
labels: ["bug: unconfirmed"]
5+
body:
6+
- type: textarea
7+
attributes:
8+
label: Summary
9+
description: |
10+
A clear and concise summary of what the bug is.
11+
placeholder: |
12+
Example bug report:
13+
When I click the "Submit" button on "Feedback", nothing happens.
14+
validations:
15+
required: true
16+
- type: input
17+
attributes:
18+
label: Page
19+
description: |
20+
What page(s) did you encounter this bug on?
21+
placeholder: |
22+
https://react.dev/
23+
validations:
24+
required: true
25+
- type: textarea
26+
attributes:
27+
label: Details
28+
description: |
29+
Please provide any additional details about the bug.
30+
placeholder: |
31+
Example details:
32+
The "Submit" button is unresponsive. I've tried refreshing the page and using a different browser, but the issue persists.
33+
validations:
34+
required: false

.github/ISSUE_TEMPLATE/1-typo.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: "🤦 Typo or mistake"
2+
description: "Report a typo or mistake in the docs."
3+
title: "[Typo]: "
4+
labels: ["type: typos"]
5+
body:
6+
- type: textarea
7+
attributes:
8+
label: Summary
9+
description: |
10+
A clear and concise summary of what the mistake is.
11+
placeholder: |
12+
Example:
13+
The code example on the "useReducer" page includes an unused variable `nextId`.
14+
validations:
15+
required: true
16+
- type: input
17+
attributes:
18+
label: Page
19+
description: |
20+
What page is the typo on?
21+
placeholder: |
22+
https://react.dev/
23+
validations:
24+
required: true
25+
- type: textarea
26+
attributes:
27+
label: Details
28+
description: |
29+
Please provide a explanation for why this is a mistake.
30+
placeholder: |
31+
Example mistake:
32+
In the "useReducer" section of the "API Reference" page, the code example under "Writing a reducer function" includes an unused variable `nextId` that should be removed.
33+
validations:
34+
required: false
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: "💡 Suggestions"
2+
description: "Suggest a new page, section, or edit for an existing page."
3+
title: "[Suggestion]: "
4+
labels: ["type: documentation"]
5+
body:
6+
- type: textarea
7+
attributes:
8+
label: Summary
9+
description: |
10+
A clear and concise summary of what we should add.
11+
placeholder: |
12+
Example:
13+
Add a new page for how to use React with TypeScript.
14+
validations:
15+
required: true
16+
- type: input
17+
attributes:
18+
label: Page
19+
description: |
20+
What page is this about?
21+
placeholder: |
22+
https://react.dev/
23+
validations:
24+
required: false
25+
- type: textarea
26+
attributes:
27+
label: Details
28+
description: |
29+
Please provide a explanation for what you're suggesting.
30+
placeholder: |
31+
Example:
32+
I think it would be helpful to have a page that explains how to use React with TypeScript. This could include a basic example of a component written in TypeScript, and a link to the TypeScript documentation.
33+
validations:
34+
required: true
+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: "📄 Suggest new framework"
2+
description: "I am a framework author applying to be included as a recommended framework."
3+
title: "[Framework]: "
4+
labels: ["type: framework"]
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
## Apply to be included as a recommended React framework
10+
11+
_This form is for framework authors to apply to be included as a recommended [React framework](https://react.dev/learn/start-a-new-react-project). If you are not a framework author, please contact the authors before submitting._
12+
13+
Our goal when recommending a framework is to start developers with a React project that solves common problems like code splitting, data fetching, routing, and HTML generation without any extra work later. We believe this will allow users to get started quickly with React, and scale their app to production.
14+
15+
While we understand that many frameworks may want to be featured, this page is not a place to advertise every possible React framework or all frameworks that you can add React to. There are many great frameworks that offer support for React that are not listed in our guides. The frameworks we recommend have invested significantly in the React ecosystem, and collaborated with the React team to be compatible with our [full-stack React architecture vision](https://react.dev/learn/start-a-new-react-project#which-features-make-up-the-react-teams-full-stack-architecture-vision).
16+
17+
To be included, frameworks must meet the following criteria:
18+
19+
- **Free & open-source**: must be open source and free to use.
20+
- **Well maintained**. must be actively maintained, providing bug fixes and improvements.
21+
- **Active community**: must have a sufficiently large and active community to support users.
22+
- **Clear onboarding**: must have clear install steps to install the React version of the framework.
23+
- **Ecosystem compatibility**: must support using the full range of libraries and tools in the React ecosystem.
24+
- **Self-hosting option**: must support an option to self-host applications without losing access to features.
25+
- **Developer experience**. must allow developers to be productive by supporting features like Fast Refresh.
26+
- **User experience**. must provide built-in support for common problems like routing and data-fetching.
27+
- **Compatible with our future vision for React**. React evolves over time, and frameworks that do not align with React’s direction risk isolating their users from the main React ecosystem over time. To be included on this page we must feel confident that the framework is setting its users up for success with React over time.
28+
29+
Please note, we have reviewed most of the popular frameworks available today, so it is unlikely we have not considered your framework already. But if you think we missed something, please complete the application below.
30+
- type: input
31+
attributes:
32+
label: Name
33+
description: |
34+
What is the name of your framework?
35+
validations:
36+
required: true
37+
- type: input
38+
attributes:
39+
label: Homepage
40+
description: |
41+
What is the URL of your homepage?
42+
validations:
43+
required: true
44+
- type: input
45+
attributes:
46+
label: Install instructions
47+
description: |
48+
What is the URL of your getting started guide?
49+
validations:
50+
required: true
51+
- type: dropdown
52+
attributes:
53+
label: Is your framework open source?
54+
description: |
55+
We only recommend free and open source frameworks.
56+
options:
57+
- 'No'
58+
- 'Yes'
59+
validations:
60+
required: true
61+
- type: textarea
62+
attributes:
63+
label: Well maintained
64+
description: |
65+
Please describe how your framework is actively maintained. Include recent releases, bug fixes, and improvements as examples.
66+
validations:
67+
required: true
68+
- type: textarea
69+
attributes:
70+
label: Active community
71+
description: |
72+
Please describe your community. Include the size of your community, and links to community resources.
73+
validations:
74+
required: true
75+
- type: textarea
76+
attributes:
77+
label: Clear onboarding
78+
description: |
79+
Please describe how a user can install your framework with React. Include links to any relevant documentation.
80+
validations:
81+
required: true
82+
- type: textarea
83+
attributes:
84+
label: Ecosystem compatibility
85+
description: |
86+
Please describe any limitations your framework has with the React ecosystem. Include any libraries or tools that are not compatible with your framework.
87+
validations:
88+
required: true
89+
- type: textarea
90+
attributes:
91+
label: Self-hosting option
92+
description: |
93+
Please describe how your framework supports self-hosting. Include any limitations to features when self-hosting. Also include whether you require a server to deploy your framework.
94+
validations:
95+
required: true
96+
- type: textarea
97+
attributes:
98+
label: Developer Experience
99+
description: |
100+
Please describe how your framework provides a great developer experience. Include any limitations to React features like React DevTools, Chrome DevTools, and Fast Refresh.
101+
validations:
102+
required: true
103+
- type: textarea
104+
attributes:
105+
label: User Experience
106+
description: |
107+
Please describe how your framework helps developers create high quality user experiences by solving common use-cases. Include specifics for how your framework offers built-in support for code-splitting, routing, HTML generation, and data-fetching in a way that avoids client/server waterfalls by default. Include details on how you offer features such as SSG and SSR.
108+
validations:
109+
required: true
110+
- type: textarea
111+
attributes:
112+
label: Compatible with our future vision for React
113+
description: |
114+
Please describe how your framework aligns with our future vision for React. Include how your framework will evolve with React over time, and your plans to support future React features like React Server Components.
115+
validations:
116+
required: true

.github/ISSUE_TEMPLATE/config.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
contact_links:
2+
- name: 📃 Bugs in React
3+
url: https://github.com/facebook/react/issues/new/choose
4+
about: This issue tracker is not for bugs in React. Please file React issues here.
5+
- name: 🤔 Questions and Help
6+
url: https://reactjs.org/community/support.html
7+
about: This issue tracker is not for support questions. Please refer to the React community's help and discussion forums.

src/components/MDX/InlineCode.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
import cn from 'classnames';
66

77
interface InlineCodeProps {
8-
isLink: boolean;
8+
isLink?: boolean;
9+
meta?: string;
910
}
1011
function InlineCode({
1112
isLink,

src/components/MDX/MDXComponents.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import Link from './Link';
1919
import {PackageImport} from './PackageImport';
2020
import Recap from './Recap';
2121
import Sandpack from './Sandpack';
22+
import SandpackWithHTMLOutput from './SandpackWithHTMLOutput';
2223
import Diagram from './Diagram';
2324
import DiagramGroup from './DiagramGroup';
2425
import SimpleCallout from './SimpleCallout';
@@ -434,6 +435,7 @@ export const MDXComponents = {
434435
Recap,
435436
Recipes,
436437
Sandpack,
438+
SandpackWithHTMLOutput,
437439
TeamMember,
438440
TerminalBlock,
439441
YouWillLearn,

src/components/MDX/Sandpack/createFileMap.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ export const SUPPORTED_FILES = [AppJSPath, StylesCSSPath];
1111
export const createFileMap = (codeSnippets: any) => {
1212
return codeSnippets.reduce(
1313
(result: Record<string, SandpackFile>, codeSnippet: React.ReactElement) => {
14-
if ((codeSnippet.type as any).mdxName !== 'pre') {
14+
if (
15+
(codeSnippet.type as any).mdxName !== 'pre' &&
16+
codeSnippet.type !== 'pre'
17+
) {
1518
return result;
1619
}
1720
const {props} = codeSnippet.props.children;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import {Children, memo} from 'react';
2+
import InlineCode from './InlineCode';
3+
import Sandpack from './Sandpack';
4+
5+
const ShowRenderedHTML = `
6+
import { renderToStaticMarkup } from 'react-dom/server';
7+
import formatHTML from './formatHTML.js';
8+
9+
export default function ShowRenderedHTML({children}) {
10+
const markup = renderToStaticMarkup(
11+
<html>
12+
<head />
13+
<body>{children}</body>
14+
</html>
15+
);
16+
return (
17+
<>
18+
<h1>Rendered HTML:</h1>
19+
<pre>
20+
{formatHTML(markup)}
21+
</pre>
22+
</>
23+
);
24+
}`;
25+
26+
const formatHTML = `
27+
import format from 'html-format';
28+
29+
export default function formatHTML(markup) {
30+
// Cheap tricks to format the HTML readably -- haven't been able to
31+
// find a package that runs in browser and prettifies the HTML if it
32+
// lacks line-breaks.
33+
return format(markup
34+
.replace('<html>', '<html>\\n')
35+
.replace('<head>', '<head>\\n')
36+
.replaceAll(/<\\/script>/g, '<\\/script>\\n')
37+
.replaceAll(/<style([^>]*)\\/>/g, '<style $1/>\\n\\n')
38+
.replaceAll(/<\\/style>/g, '\\n <\\/style>\\n')
39+
.replaceAll(/<link([^>]*)\\/>/g, '<link $1/>\\n')
40+
.replaceAll(/<meta([^/]*)\\/>/g, '<meta $1/>\\n')
41+
.replace('</head>', '</head>\\n')
42+
.replace('<body>', '<body>\\n')
43+
.replace('</body>', '\\n</body>\\n')
44+
.replace('</h1>', '</h1>\\n')
45+
);
46+
}
47+
`;
48+
49+
const packageJSON = `
50+
{
51+
"dependencies": {
52+
"react": "18.3.0-canary-6db7f4209-20231021",
53+
"react-dom": "18.3.0-canary-6db7f4209-20231021",
54+
"react-scripts": "^5.0.0",
55+
"html-format": "^1.1.2"
56+
},
57+
"main": "/index.js",
58+
"devDependencies": {}
59+
}
60+
`;
61+
62+
// Intentionally not a React component because <Sandpack> will read
63+
// through its childrens' props. This imitates the output of ```
64+
// codeblocks in MDX.
65+
function createFile(meta: string, source: string) {
66+
return (
67+
<pre key={meta}>
68+
<InlineCode meta={meta} className="language-js">
69+
{source}
70+
</InlineCode>
71+
</pre>
72+
);
73+
}
74+
75+
export default memo(function SandpackWithHTMLOutput(
76+
props: React.ComponentProps<typeof Sandpack>
77+
) {
78+
const children = [
79+
...Children.toArray(props.children),
80+
createFile('ShowRenderedHTML.js', ShowRenderedHTML),
81+
createFile('formatHTML.js hidden', formatHTML),
82+
createFile('package.json hidden', packageJSON),
83+
];
84+
return <Sandpack {...props}>{children}</Sandpack>;
85+
});

0 commit comments

Comments
 (0)