Skip to content
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

× Error: Invalid hook call. #5

Open
dylannirvana opened this issue May 6, 2021 · 8 comments
Open

× Error: Invalid hook call. #5

dylannirvana opened this issue May 6, 2021 · 8 comments
Labels
help wanted Extra attention is needed

Comments

@dylannirvana
Copy link

dylannirvana commented May 6, 2021

Trying to bring Convertkit form into a React application. Directly using the JavaScript embed provided by CK <script async data-uid="e9274113f5" src="https://astounding-creator-7935.ck.page/e9274113f5/index.js"></script> does not work as-is in React. Using convertkit-react, the connection is made but the template is not being brought in. I am getting: Error: Invalid hook call.

The example usage does not show the code in relation to the render() function.

This is the standalone form https://astounding-creator-7935.ck.page/e9274113f5

import Container from 'react-bootstrap/Container'
import ConvertKitForm from 'convertkit-react'

const MY_FORM_ID = 2248904
class Convertkit extends React.Component {   

      render() {  
        const config = {
            formId: MY_FORM_ID,
            template: 'cocoa',
            // emailPlaceholder: 'Enter an email address',
            // submitText: 'Sign up',
          }
          
          return (
                <Container className="section">
                    <p>Yo</p>
                    <ConvertKitForm {...config} />

                </Container>                                  
        )
    }
}

export default Convertkit;```
@dylannirvana
Copy link
Author

dylannirvana commented May 6, 2021

Simplified version below still gets ERROR: invalid hook call

import ConvertKitForm from 'convertkit-react'

function Convertkit() {
    const MY_FORM_ID = 2248904
    const config = {
        formId: MY_FORM_ID,
        template: 'cocoa',
        // emailPlaceholder: 'Enter an email address',
        // submitText: 'Sign up',
      }
    
      return (
        <ConvertKitForm {...config} />
      )
  }

export default Convertkit;```

@rug1
Copy link

rug1 commented May 8, 2021

I'm getting the same problem...the link to the react docs in the error message makes me think that it's either this library has listed the dependency incorrectly which then breaks our dependency tree or the library is using hooks incorrectly. Would be great to get a fix in for this. My project is using react v17.

Screenshot 2021-05-08 at 20 21 45

@josephrexme josephrexme added bug Something isn't working help wanted Extra attention is needed and removed bug Something isn't working labels May 31, 2021
@josephrexme
Copy link
Collaborator

@perrycipolloni I'm sorry convertkit-react does not support versions of React that do not support hooks. You didn't specify what version you are using but I'm assuming that from your need to use it in a class, it's probably an older version of React you have. Let me know if I'm wrong with that assumption.

@rug1 I might need a little more clarity on your setup. Could it be that you have different versions of React and ReactDOM? This package relies on your installed version of React and has no other dependencies.

@josephrexme josephrexme removed the help wanted Extra attention is needed label May 31, 2021
@josephrexme
Copy link
Collaborator

I'll close this for now as I'm unable to reproduce on recent versions of React

@josephrexme
Copy link
Collaborator

Was able to reproduce this Today and noticed that using a different patch version from the one the library uses (17.0.2) still causes the error for React 17 users. Will work on a fix soon

@josephrexme josephrexme reopened this Jun 13, 2021
@josephrexme josephrexme added the help wanted Extra attention is needed label Jun 13, 2021
@sharmaed
Copy link

Curious, do we have an update for this error? Or good work around in the meantime?

@hinsencamp
Copy link

Issue still exists. @josephrexme any plans to fix this?

@schematical
Copy link

schematical commented Dec 22, 2023

I am getting this issue with the following:


    "react": "^18.2.0",
    "react-cookie": "^4.0.3",
    "react-dom": "^18.2.0",
    "react-ga4": "^2.0.0",
    "react-https-redirect": "^1.1.0",
    "react-owl-carousel": "^2.3.1",
    "react-router-component": "^0.39.1",
    "react-router-dom": "^6.21.0",
    "react-scripts": "^5.0.1",
    ```
    Also this only happens when I add a `theme` option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants