This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useState, useCallback, useEffect } from 'react'; | |
| import {render} from "react-dom"; | |
| let resolve; | |
| const Confirm = ({ refShow }) => { | |
| const [isOpen, setIsOpen] = useState(false); | |
| const handleCancel = useCallback(() => { | |
| setIsOpen(false); | |
| resolve(false); | |
| }, []); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // imports | |
| import confirmService from './confirmService'; | |
| class App extends Component { | |
| // constructor | |
| async removeItem({ target: { value } }) { | |
| const result = await confirmService.show(); | |
| if (result) { | |
| const items = this.state.items.filter((item, index) => index !== parseInt(value)); | |
| this.setState({ items }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Confirm from './Confirm'; | |
| export default Confirm.create(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let resolve; | |
| class Confirm extends Component { | |
| // rest of the componet | |
| handleCancel() { | |
| this.setState({isOpen: false}); | |
| resolve(false); | |
| } | |
| handleConfirm() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Confirm extends Component { | |
| static create() { | |
| const containerElement = document.createElement('div'); | |
| document.body.appendChild(containerElement); | |
| return render(<Confirm/>, containerElement); | |
| } | |
| // .., rest of the component | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from 'react'; | |
| import { render } from 'react-dom'; | |
| class Confirm extends Component { | |
| constructor() { | |
| super(); | |
| this.state = { | |
| isOpen: false, | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, {Component} from 'react'; | |
| import {render} from 'react-dom'; | |
| import 'bulma'; | |
| class App extends Component { | |
| constructor() { | |
| // rest of constructor | |
| this.removeItem = this.removeItem.bind(this); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class App extends Component { | |
| // constructor | |
| render() { | |
| return ( | |
| <div className="container-fluid"> | |
| <h1 className="is-size-2">React Confirm as a Service</h1> | |
| <p>try to delete one</p> | |
| <h2>TODO:</h2> | |
| <div className="columns is-mobile is-multiline"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class App extends Component { | |
| constructor() { | |
| super(); | |
| this.state = { | |
| items: [ | |
| 'Eat hamburger', | |
| 'Drink coke', | |
| 'Go to bathroom' | |
| ] | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from 'react'; | |
| import { render } from 'react-dom'; | |
| import 'bulma'; | |
| class App extends Component { | |
| render() { | |
| return (<div className="container-fluid">Hello </div>); | |
| } | |
| } |