@@ -35,7 +35,7 @@ const ExampleComponent = () => {
3535
3636 useEffect (() => {
3737 setMarkdownSource (' # markdown header' );
38- }, [])
38+ }, []);
3939
4040 return reactContent ;
4141};
@@ -66,6 +66,23 @@ const ExampleComponent = () => {
6666export default ExampleComponent ;
6767```
6868
69+ ### Server side rendering
70+
71+ ``` tsx
72+ import React from ' react' ;
73+ import { useRemarkSync } from ' react-remark' ;
74+
75+ const ExampleComponent = () => {
76+ const reactContent = useRemarkSync (' # markdown header' );
77+
78+ return reactContent ;
79+ };
80+
81+ export default ExampleComponent ;
82+ ```
83+
84+ :notebook : Note that some remark plugins are async, these plugins will error if used with ` useRemarkSync ` .
85+
6986[ More examples of usage as hook in storybook.] ( https://remarkjs.github.io/react-remark/?path=/story/remark-hook )
7087
7188### As a component
@@ -155,13 +172,12 @@ import rehypeAutoLinkHeadings from 'rehype-autolink-headings';
155172// ...
156173
157174const [reactContent, setMarkdownSource] = useRemark ({
158- remarkParseOptions: { commonmark: true },
159175 remarkPlugins: [remarkGemoji ],
160- remarkToRehypeOptions: { commonmark : true },
176+ remarkToRehypeOptions: { allowDangerousHtml : true },
161177 rehypePlugins: [rehypeSlug , rehypeAutoLinkHeadings ],
162178 rehypeReactOptions: {
163179 components: {
164- p : props => <p className = " custom-paragraph" { ... props } />,
180+ p : ( props ) => <p className = " custom-paragraph" { ... props } />,
165181 },
166182 },
167183});
@@ -179,13 +195,12 @@ import rehypeAutoLinkHeadings from 'rehype-autolink-headings';
179195// ...
180196
181197<Remark
182- remarkParseOptions = { { commonmark: true }}
183198 remarkPlugins = { [remarkGemoji ]}
184- remarkToRehypeOptions = { { commonmark : true }}
199+ remarkToRehypeOptions = { { allowDangerousHtml : true }}
185200 rehypePlugins = { [rehypeSlug , rehypeAutoLinkHeadings ]}
186201 rehypeReactOptions = { {
187202 components: {
188- p : props => <p className = " custom-paragraph" { ... props } />,
203+ p : ( props ) => <p className = " custom-paragraph" { ... props } />,
189204 },
190205 }}
191206>
0 commit comments