Skip to content

Commit

Permalink
Covert HelloWorld to TSX
Browse files Browse the repository at this point in the history
  • Loading branch information
justin808 committed Aug 3, 2020
1 parent 87ff0c5 commit 6acb4d3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import PropTypes from 'prop-types';
import React, { useState } from 'react';
import * as React from 'react';
import { useState, FunctionComponent } from 'react';

const HelloWorld = (props) => {
export interface Props {
name: string;
}

// Note, you need to declare the type so that ReactOnRails.register has the
// proper type.
const HelloWorld: FunctionComponent<Props> = (props: Props) => {
const [name, setName] = useState(props.name);

return (
Expand All @@ -18,8 +24,4 @@ const HelloWorld = (props) => {
);
};

HelloWorld.propTypes = {
name: PropTypes.string.isRequired, // this is passed from the Rails view
};

export default HelloWorld;
File renamed without changes.

0 comments on commit 6acb4d3

Please sign in to comment.