docs: remove this
usage from function component (#29596)
Fix a small error in the `next/script` docs. Let me know if you'd like a `useState` for the sake of a complete example. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes
This commit is contained in:
parent
c06a3c1731
commit
1c1929b3a5
1 changed files with 4 additions and 1 deletions
|
@ -109,16 +109,19 @@ export default function Home() {
|
||||||
### Executing Code After Loading (`onLoad`)
|
### Executing Code After Loading (`onLoad`)
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
import { useState } from 'react'
|
||||||
import Script from 'next/script'
|
import Script from 'next/script'
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
|
const [stripe, setStripe] = useState(null)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Script
|
<Script
|
||||||
id="stripe-js"
|
id="stripe-js"
|
||||||
src="https://js.stripe.com/v3/"
|
src="https://js.stripe.com/v3/"
|
||||||
onLoad={() => {
|
onLoad={() => {
|
||||||
this.setState({ stripe: window.Stripe('pk_test_12345') })
|
setStripe({ stripe: window.Stripe('pk_test_12345') })
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
|
|
Loading…
Reference in a new issue