-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
161 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,58 @@ Let's start with installing `@perawallet/connect` | |
npm install --save @perawallet/connect | ||
``` | ||
|
||
<details> | ||
<summary>Using with React 18</summary><br/> | ||
|
||
When you want to use `@perawallet/connect` library with React 18, you need to make some changes. `react-scripts` stopped polyfilling some of the packages with the `[email protected]` version. After creating a new app with `npx create-react-app my-app` or in your react application, the following changes should be made. | ||
|
||
1. Firstly, install the following packages. | ||
|
||
```sh | ||
npm install buffer | ||
npm install crypto-browserify | ||
npm install process | ||
npm install react-app-rewired | ||
npm install stream-browserify | ||
``` | ||
|
||
2. After that you need to override some webpack features. Create the following file in the root directory of the project and copy the following code block into it. | ||
|
||
`config-overrides.js` | ||
|
||
```jsx | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const webpack = require("webpack"); | ||
|
||
module.exports = function override(config) { | ||
const fallback = config.resolve.fallback || {}; | ||
|
||
Object.assign(fallback, { | ||
crypto: require.resolve("crypto-browserify"), | ||
stream: require.resolve("stream-browserify") | ||
}); | ||
config.resolve.fallback = fallback; | ||
// ignore warning about source map of perawallet/connect | ||
|
||
config.ignoreWarnings = [/Failed to parse source map/]; | ||
config.plugins = (config.plugins || []).concat([ | ||
new webpack.ProvidePlugin({ | ||
process: "process/browser", | ||
Buffer: ["buffer", "Buffer"] | ||
}) | ||
]); | ||
return config; | ||
}; | ||
``` | ||
|
||
3. Finally, you need to update the npm scripts. | ||
|
||
`{ "start": "react-app-rewired start", "build": "react-app-rewired build" }` | ||
|
||
After that, you are good to go! 🎊 | ||
|
||
</details> | ||
|
||
#### Using React Hooks | ||
|
||
```typescript | ||
|
Oops, something went wrong.