Closed CaiIsProgrammer closed 3 years ago
What are the steps you used to create the app? Are you trying to create a remote-component or are you trying to use a remote-component? Do you have a link to a repo that reproduces this bug that I can look at?
i just used the example you provided and it didnt work. So i guess the repo would just be your example. i havent done anything else to it and i dont have it on git sadly.
Are you trying to create a remote-component or are you trying to use a remote-component?
I just ran through the example directions on remote-component-starter and everything appears to be working properly.
I am going to need more info on how to reproduce your error.
Are you getting the error in the remote-component-starter
or in a create react app?
Are you trying to build a remote component or are you trying to add one into a react app?
Is this error during the build step? If so, what command are you running?
Is the error in the browser?
So yeah in dev mode is the error. I'm trying to first just import the one in the example. I want to add remote components made by users to a DB and then render them on the site after inspection of their components. Though I don't want to add all their components one by one into my app.
error is in create react app
so i recreated in code sandbox and i still cant get it to work. https://codesandbox.io/s/shy-sky-k8spz?file=/src/App.js
so i recreated in code sandbox and i still cant get it to work. https://codesandbox.io/s/shy-sky-k8spz?file=/src/App.js
First, the error you are seeing is unrelated to remote component
Inside of your src/App.js
, make this change. Comment the render and add a default export.
// ReactDOM.render(<HelloWorld name="Paciolan" />, element);
export default HelloWorld;
Now you will see an error from the remote component
Unknown Error: DependencyNotFoundError: Could not find dependency: 'remote-component.config.js' relative to '/node_modules/@paciolan/remote-component/dist/getDependencies.js'
So now you have to add the dependencies, like react
.
Because you are not using webpack, follow the directions here: https://github.com/Paciolan/remote-component#injecting-dependencies-without-webpack
create remote-component.config.js
at the root.
/**
* Dependencies for Remote Components
*/
module.exports = {
resolve: {
react: require("react")
}
};
Create src/RemoteComponent.js
and import the dependencies from remote-component.config.js
.
import {
createRemoteComponent,
createRequires
} from "@paciolan/remote-component";
import { resolve } from "../remote-component.config.js";
const requires = createRequires(resolve);
export const RemoteComponent = createRemoteComponent({ requires });
Last, in your src/App.js
, change it to import the custom RemoteComponent
.
import { RemoteComponent } from "./components/RemoteComponent";
const url = "https://raw.githubusercontent.com/Paciolan/remote-component/master/examples/remote-components/HelloWorld.js"; // prettier-ignore
const HelloWorld = (props) => <RemoteComponent url={url} {...props} />;
export default HelloWorld;
so trying to run your example on here i get this error
`TypeError: react_1.useState is not a function useRemoteComponent C:/Users/cmart/Desktop/New folder/node_modules/@paciolan/remote-component/dist/hooks/useRemoteComponent.js:20 17 | var loadRemoteModule = remote_module_loader_1"default"; 18 | 19 | var useRemoteComponent = function useRemoteComponent(url) {