Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@shopify/react-html
Advanced tools
@shopify/react-html
$ yarn add @shopify/react-html
The <HTML>
component serves as a top level wrapper for a react application, allowing you to avoid needing any kind of server side template, in favour of purely using reactDom.renderToString
.
import * as React from 'react';
import { renderToString } from 'react-dom/server';
import HTML from '@shopify/react-html';
import MyApp from '../app';
export default (ctx, next) => {
ctx.body = renderToString(
<HTML>
<MyApp />
</HTML>
);
await next();
}
The component will automatically propagate any usage of the react-helmet
module in your app's content to manipulate the title or other top level HTML or HEAD attributes.
export interface Props {
children?: React.ReactNode;
styles?: Asset[];
synchronousScripts?: Asset[];
deferedScripts?: Asset[];
headData?: {[id: string]: any};
data?: {[id: string]: any};
}
interface Asset {
path: string;
integrity?: string;
}
interface Browser {
userAgent: string;
supported: boolean;
}
Most simple applications will only need these basic properties.
children
The children to be rendered inside the #app
div.
styles Descriptors for any style tags you want to include in the HEAD of the document.
synchronousScripts Descriptors for any script tags you want to include in the HEAD of the document.
deferredScripts Descriptors for any deferred script tags you want to include at the end of the document.
These props are useful for more complex applications that want to synchronize redux, apollo, translation, or any other data across the network boundary. These props are stringified into the DOM using (@shopify/react-serialize
)[https://github.com/Shopify/quilt/blob/master/packages/react-serialize/README.md].
headData
Any serializable data that needs to be available from the DOM when the synchronousScripts
are run.
data
Any serializable data that needs to be available from the DOM when the deferredScripts
are run.
FAQs
A component to render your React app with no static HTML
The npm package @shopify/react-html receives a total of 14,830 weekly downloads. As such, @shopify/react-html popularity was classified as popular.
We found that @shopify/react-html demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.