Skip to content

Commit

Permalink
chore: upd sandbox to use input
Browse files Browse the repository at this point in the history
  • Loading branch information
limonte committed Oct 31, 2023
1 parent ebf161b commit 7f3b0a1
Show file tree
Hide file tree
Showing 2 changed files with 1,230 additions and 1,084 deletions.
34 changes: 28 additions & 6 deletions test/sandbox.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import React, { useState } from 'react'
import Swal from 'sweetalert2/dist/sweetalert2.all'
import withReactContent from '../src/index'

let MySwal = withReactContent(Swal)

MySwal.fire({
icon: 'success',
title: <i>Test</i>,
html: <i>Hello World</i>,
})
function App() {
const [inputValue, setInputValue] = useState('')

function showSwal() {
MySwal.fire({
title: <i>Input something</i>,
input: 'text',
inputValue,
didOpen: () => setSwalShown(true),
didClose: () => setSwalShown(false),
confirmButtonText: <i>Submit</i>,
preConfirm: () => {
setInputValue(Swal.getInput().value || '')
},
})
}

return (
<>
<button onClick={() => showSwal()}>show swal</button>
<div>input value: {inputValue}</div>
</>
)
}

ReactDOM.createRoot(document.getElementById('root')).render(<App />)
Loading

0 comments on commit 7f3b0a1

Please sign in to comment.