chore: Migrate LoadMore room to ts

This commit is contained in:
AlexAlexandre 2021-12-02 18:19:52 -03:00
parent 46cf0f8e6f
commit 6e5df501cb
2 changed files with 8 additions and 9 deletions

View File

@ -28,7 +28,7 @@ stories.add('basic', () => (
</>
));
const ThemeStory = ({ theme }) => (
const ThemeStory = ({ theme }: { theme: string }) => (
<ThemeContext.Provider value={{ theme }}>
<ScrollView style={{ backgroundColor: themes[theme].backgroundColor }}>
<LoadMore load={load} type={MESSAGE_TYPE_LOAD_PREVIOUS_CHUNK} />

View File

@ -1,6 +1,5 @@
import React, { useCallback, useEffect, useState } from 'react';
import { ActivityIndicator, StyleSheet, Text } from 'react-native';
import PropTypes from 'prop-types';
import { themes } from '../../../constants/colors';
import { MESSAGE_TYPE_LOAD_NEXT_CHUNK, MESSAGE_TYPE_LOAD_PREVIOUS_CHUNK } from '../../../constants/messageTypeLoad';
@ -21,7 +20,13 @@ const styles = StyleSheet.create({
}
});
const LoadMore = ({ load, type, runOnRender }) => {
interface IRoomLoadMoreProps {
load(): Promise<unknown>;
type?: string;
runOnRender?: boolean;
}
const LoadMore = ({ load, type, runOnRender }: IRoomLoadMoreProps) => {
const { theme } = useTheme();
const [loading, setLoading] = useState(false);
@ -62,10 +67,4 @@ const LoadMore = ({ load, type, runOnRender }) => {
);
};
LoadMore.propTypes = {
load: PropTypes.func,
type: PropTypes.string,
runOnRender: PropTypes.bool
};
export default LoadMore;