diff --git a/.eslintrc.js b/.eslintrc.js index b051dcd691f..904d95c171a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -200,6 +200,7 @@ module.exports = { 'examples/node-xhr/*.js', 'examples/php-xhr/*.js', 'examples/python-xhr/*.js', + 'examples/react-example/*.js', 'examples/transloadit/*.js', 'examples/transloadit-markdown-bin/*.js', 'examples/xhr-bundle/*.js', diff --git a/examples/react-example/.babelrc.js b/examples/react-example/.babelrc.js deleted file mode 100644 index 38ec4e9dce1..00000000000 --- a/examples/react-example/.babelrc.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - presets: [ - '@babel/preset-react' - ] -} diff --git a/examples/react-example/.gitignore b/examples/react-example/.gitignore deleted file mode 100644 index b4a92dadece..00000000000 --- a/examples/react-example/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -bundle.js -uppy.min.css -bundle.js.* diff --git a/examples/react-example/App.js b/examples/react-example/App.jsx similarity index 83% rename from examples/react-example/App.js rename to examples/react-example/App.jsx index 663f2d4d666..064d07422f9 100644 --- a/examples/react-example/App.js +++ b/examples/react-example/App.jsx @@ -1,11 +1,17 @@ /* eslint-disable */ -const React = require('react') -const Uppy = require('@uppy/core') -const Tus = require('@uppy/tus') -const GoogleDrive = require('@uppy/google-drive') -const { Dashboard, DashboardModal, DragDrop, ProgressBar, FileInput } = require('@uppy/react') +import React from'react' +import Uppy from'@uppy/core' +import Tus from'@uppy/tus' +import GoogleDrive from'@uppy/google-drive' +import { Dashboard, DashboardModal, DragDrop, ProgressBar, FileInput } from'@uppy/react' -module.exports = class App extends React.Component { +import '@uppy/core/dist/style.css' +import '@uppy/dashboard/dist/style.css' +import '@uppy/drag-drop/dist/style.css' +import '@uppy/file-input/dist/style.css' +import '@uppy/progress-bar/dist/style.css' + +export default class App extends React.Component { constructor (props) { super(props) diff --git a/examples/react-example/README.md b/examples/react-example/README.md new file mode 100644 index 00000000000..8237b6177a1 --- /dev/null +++ b/examples/react-example/README.md @@ -0,0 +1,30 @@ +# React example + +This is minimal example created to demonstrate how to integrate Uppy in your +React app. + +To spawn the demo, use the following commands: + +```sh +corepack yarn install +corepack yarn build +corepack yarn workspace @uppy-example/react dev +``` + +If you'd like to use a different package manager than Yarn (e.g. npm) to work +with this example, you can extract it from the workspace like this: + +```sh +corepack yarn workspace @uppy-example/react pack + +# The above command should have create a .tgz file, we're going to extract it to +# a new directory outside of the Uppy workspace. +mkdir ../react-example +tar -xzf examples/react-example/package.tgz -C ../react-example --strip-components 1 +rm -f examples/react-example/package.tgz + +# Now you can leave the Uppy workspace and use the example as a standalone JS project: +cd ../react-example +npm i +npm run dev +``` diff --git a/examples/react-example/index.html b/examples/react-example/index.html index 37b788d39ab..be17dd91ffb 100644 --- a/examples/react-example/index.html +++ b/examples/react-example/index.html @@ -8,6 +8,6 @@
- +