Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the React example to use functional component #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rememberlenny
Copy link

The React example is using an outdated webpack file and React version.

This updates the component to use a functional definition, rather than the class. More improvements could be made.

Removing the class example to modernize the React best practices.
Removing the class example to modernize the React best practices.

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 = () => {

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants