Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions react/src/ui.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
import * as React from 'react'
import * as ReactDOM from 'react-dom'
import './ui.css'
import Logo from './logo.svg'

declare function require(path: string): any

class App extends React.Component {
textbox: HTMLInputElement
const App = () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the following is better

Suggested change
const App = () => {
const App: React.FC = () => {

let textbox: HTMLInputElement;

countRef = (element: HTMLInputElement) => {
const countRef = (element: HTMLInputElement) => {
if (element) element.value = '5'
this.textbox = element
textbox = element
}

onCreate = () => {
const count = parseInt(this.textbox.value, 10)
const onCreate = () => {
const count = parseInt(textbox.value, 10)
parent.postMessage({ pluginMessage: { type: 'create-rectangles', count } }, '*')
}

onCancel = () => {
const onCancel = () => {
parent.postMessage({ pluginMessage: { type: 'cancel' } }, '*')
}

render() {
Copy link

@shuta13 shuta13 Jul 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the render() is necessary, just return should do it.

return <div>
<img src={require('./logo.svg')} />
<img src={Logo} />
<h2>Rectangle Creator</h2>
<p>Count: <input ref={this.countRef} /></p>
<button id="create" onClick={this.onCreate}>Create</button>
<button onClick={this.onCancel}>Cancel</button>
<p>Count: <input ref={countRef} /></p>
<button id="create" onClick={onCreate}>Create</button>
<button onClick={onCancel}>Cancel</button>
</div>
}
}
Expand Down