-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initializing SDK in React Project #74
Comments
same issue here |
try to run the command in your root folder of the project
|
Thank you. That resolves my errors but I get new error:
|
@saleos97 you can do the same for that error, 'npm install buffer' You can take a look at a template I made here, specially for the webpack config-overrides.js: https://github.com/willsmillie/Loopring-token-gate-react-example |
i have that buffer error too although i ran this command
I changed the webpack.config.js to config-overrides.js with this code: const webpack = require("webpack");
module.exports = function override(config) {
config.resolve.fallback = {
// process: require.resolve('process/browser'),
// zlib: require.resolve('browserify-zlib'),
stream: require.resolve("stream-browserify"),
// util: require.resolve('util'),
buffer: require.resolve("buffer"),
asset: require.resolve("assert"),
};
config.plugins.push(
new webpack.ProvidePlugin({
// process: 'process/browser.js',
Buffer: ["buffer", "Buffer"],
})
);
return config;
}; this here is my package.json
and i just want to run this code here in App.tsx import React from "react";
import logo from "./logo.svg";
import "./App.css";
import { UserAPI } from "@loopring-web/loopring-sdk";
function App() {
const CHAIN_ID = 5;
const userAPI = new UserAPI({ chainId: CHAIN_ID });
console.log(userAPI);
return <div className="App"></div>;
};
export default App; @willsmillie we also start a typescript project not pure js |
@codingdani in order to modify CRA's default web pack config (via the config-overrides.js) you need to use react-app-rewired and change your react-scripts in your package.json to:
|
@willsmillie thanks! but now it throws multipe errors in the console in vscode of this kind
|
Hi,
I create a new fresh react project and I wanted to initialize the sdk with:
npx create-react-app test --template typescript npm i @loopring-web/loopring-sdk --save
I used node version v18.18.1
I used the following code into my app.tsx.
When running
I get many errors that looks like this:
Can someone help me ?
The text was updated successfully, but these errors were encountered: