Paciolan / remote-component

Dynamically load a React Component from a URL
MIT License
591 stars 49 forks source link

Show "Hooks can only be called inside of the body of a function component." after start #10

Closed jhzzzz closed 3 years ago

jhzzzz commented 3 years ago

Hi,

I use create react app, and the home page like below:

import _ from 'lodash'
import React, { Component } from 'react'

import styles from './index.module.css'
import { RemoteComponent } from '../../components/RemoteComponent'

const url = "https://raw.githubusercontent.com/Paciolan/remote-component/master/examples/remote-components/HelloWorld.js";
const HelloWorld = props => <RemoteComponent url={url} {...props} />;

class Home extends Component {
    render() {
        return (
            <div>
                <div className={styles.loginContainer}>
                    <div>START</div>
                    <HelloWorld name="Paciolan" />
                    <div>END</div>
                </div>
            </div>
        )
    }
}

export default Home

and i have follow the instruction to add webpack configs and other steps, when try to start the app, it show error like below:

image

would you help to check where the problem is, thanks.

jhzzzz commented 3 years ago

solved by delete node_modules and retry yarn install.

joelnet commented 3 years ago

I have seen this error when using npm link or React not being marked as external in the web config. It's usually a symptom of two React versions running in the same project.