1
1
mirror of https://github.com/jxnblk/mdx-deck.git synced 2024-12-02 08:03:05 +03:00
mdx-deck/docs/react.md

49 lines
984 B
Markdown
Raw Normal View History

2018-08-05 18:27:17 +03:00
# React API
2018-08-05 20:00:52 +03:00
The core mdx-deck components can also be used in any React application, such as [create-react-app][] or [next.js][].
2018-08-05 18:27:17 +03:00
### Webpack Loader
mdx-deck uses a custom webpack loader to split MDX files into an array of slides. Use this loader to import mdx files in a webpack application.
```js
// example webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.mdx$/,
ignore: /node_modules/,
use: [
'babel-loader',
'mdx-deck/loader'
]
}
]
}
}
```
### SlideDeck Component
```js
import React from 'react'
import { SlideDeck } from 'mdx-deck'
import slides from './deck.mdx'
import theme from './theme'
export default () =>
<SlideDeck
slides={slides}
theme={theme}
width='100vw'
height='100vh'
/>
```
View the source for other components available for use.
2018-08-05 19:49:27 +03:00
[create-react-app]: https://github.com/facebook/create-react-app
[next.js]: https://github.com/zeit/next.js/