@aaronhayes/react-use-hubspot-form 中文文档教程
React Use HubSpot Form Embed
将 HubSpot 表单嵌入到您的 React 组件中,使用钩子! 适用于 Create React App、Gatsby 和其他平台。
Install
$ npm install --save @aaronhayes/react-use-hubspot-form
$ yarn add @aaronhayes/react-use-hubspot-form
Getting Started
使用 HubspotProvider
包装您的应用程序。 这会将 Hubspot 脚本 添加到文档的头部。
import React from 'react';
import { HubspotProvider } from '@aaronhayes/react-use-hubspot-form';
const MyApp = () => (
<HubspotProvider>
<MyPage />
</HubspotProvider>
)
Usage
import React from 'react';
import { useHubspotForm } from '@aaronhayes/react-use-hubspot-form';
const MyPage = () => {
const { loaded, error, formCreated } = useHubspotForm({
portalId: 'XXXXXXX',
formId: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
target: '#my-hubspot-form'
});
return (
<div>
<h1>Embed Form Below</h1>
<div id="my-hubspot-form"></div>
</div>
)
}
Breaking Changes
2.0.0
- Introduction of the
HubspotProvider
component. This needs to be included in your App foruseHubspotForm
to work.
Support
如果您想将一些 sats 发送到 aaron@zbd.gg 我的 Lightning Address,我们将不胜感激。
React Use HubSpot Form Embed
Embed HubSpot forms into your React components using hooks! Works with Create React App, Gatsby and other platforms.
Install
$ npm install --save @aaronhayes/react-use-hubspot-form
$ yarn add @aaronhayes/react-use-hubspot-form
Getting Started
Wrap your application with HubspotProvider
. This will add Hubspot script to the head of your document.
import React from 'react';
import { HubspotProvider } from '@aaronhayes/react-use-hubspot-form';
const MyApp = () => (
<HubspotProvider>
<MyPage />
</HubspotProvider>
)
Usage
import React from 'react';
import { useHubspotForm } from '@aaronhayes/react-use-hubspot-form';
const MyPage = () => {
const { loaded, error, formCreated } = useHubspotForm({
portalId: 'XXXXXXX',
formId: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
target: '#my-hubspot-form'
});
return (
<div>
<h1>Embed Form Below</h1>
<div id="my-hubspot-form"></div>
</div>
)
}
Breaking Changes
2.0.0
- Introduction of the
HubspotProvider
component. This needs to be included in your App foruseHubspotForm
to work.
Support
If you feel like sending some sats to aaron@zbd.gg my Lightning Address it would be much appreciated.