Add TypeScript support for React components
This commit is contained in:
+8
-2
@@ -1,10 +1,15 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import React, { FunctionComponent, useEffect, useRef, useState } from 'react';
|
||||
|
||||
import AlphaPicker from './alphaPicker';
|
||||
|
||||
type AlphaPickerProps = {
|
||||
onAlphaPicked: () => void
|
||||
};
|
||||
|
||||
// React compatibility wrapper component for alphaPicker.js
|
||||
const AlphaPickerComponent = ({ onAlphaPicked = () => {} }) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
const AlphaPickerComponent: FunctionComponent<AlphaPickerProps> = ({ onAlphaPicked = () => {} }) => {
|
||||
const [ alphaPicker, setAlphaPicker ] = useState(null);
|
||||
const element = useRef(null);
|
||||
|
||||
@@ -19,6 +24,7 @@ const AlphaPickerComponent = ({ onAlphaPicked = () => {} }) => {
|
||||
return () => {
|
||||
alphaPicker?.destroy();
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps -- Disabled for wrapper components
|
||||
}, []);
|
||||
|
||||
return (
|
||||
Reference in New Issue
Block a user