Skip to content

Commit

Permalink
Migration PasswordInput to TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
Kmaschta committed Aug 14, 2019
1 parent 4ae3bdc commit 2cde6c8
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState } from 'react';
import React, { useState, FunctionComponent } from 'react';
import PropTypes from 'prop-types';
import { translate as withTranslation } from 'ra-core';
import { InputProps, useTranslate } from 'ra-core';
import { TextFieldProps } from '@material-ui/core/TextField';

import IconButton from '@material-ui/core/IconButton';
import InputAdornment from '@material-ui/core/InputAdornment';
Expand All @@ -9,7 +10,15 @@ import VisibilityOff from '@material-ui/icons/VisibilityOff';

import TextInput from './TextInput';

const PasswordInput = ({ translate, initiallyVisible, ...rest }) => {
interface Props extends InputProps<TextFieldProps> {
initiallyVisible?: boolean;
}

const PasswordInput: FunctionComponent<Props> = ({
initiallyVisible,
...rest
}) => {
const translate = useTranslate();
const [visible, setVisible] = useState(initiallyVisible);

return (
Expand All @@ -35,12 +44,11 @@ const PasswordInput = ({ translate, initiallyVisible, ...rest }) => {
};

PasswordInput.propTypes = {
translate: PropTypes.func.isRequired,
initiallyVisible: PropTypes.bool,
};

PasswordInput.defaultProps = {
initiallyVisible: false,
};

export default withTranslation(PasswordInput);
export default PasswordInput;

0 comments on commit 2cde6c8

Please sign in to comment.