Skip to content

Commit

Permalink
Merge pull request #64 from sdegutis/patch-1
Browse files Browse the repository at this point in the history
Add React steps to README
  • Loading branch information
FredKSchott authored Jul 25, 2019
2 parents a0663e0 + 5baa357 commit fe44a72
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,24 @@ echo '{"plugins": [["@pika/web/assets/babel-plugin.js"]]}' > .babelrc
- A Preact + HTM project: [[Source]](https://glitch.com/edit/#!/pika-web-example-preact-htm) [[Live Demo]](https://pika-web-example-preact-htm.glitch.me)
- Preact, HTM, Electron, Three.js... [See our full list of examples →](/EXAMPLES.md)

## React.js support

React is [not yet published with ES Module support](https://github.com/facebook/react/issues/11503), **however**, it is possible to get React working with @pika/web 🎉 using the following steps:

1. `npm install -P react@npm:@reactesm/react`
2. `npm install -P react-dom@npm:@reactesm/react-dom`
3. Add `react` and `react-dom` to "webDependencies" if you've added that to package.json (see Options below)
4. Run @pika/web with `npx @pika/web`, or with `npm install` if you have the aforementioned "prepare" script installed

After following these instructions, your `node_modules/react` and `node_modules/react-dom` directories in your project will be ESM-compatible versions of production-ready React and ReactDOM! Now just import it into any JavaScript file like so:

```js
import React from './web_modules/react.js';
// also supports destructuring:
import { useState } from './web_modules/react.js';
```

Note that [any ESM-compatible React libraries](https://www.pika.dev/search?q=react-) can now be installed and turned into web_modules files! 🎉

## Performance

Expand Down

0 comments on commit fe44a72

Please sign in to comment.