chore: Migrate LoadMore room to ts
This commit is contained in:
parent
46cf0f8e6f
commit
6e5df501cb
|
@ -28,7 +28,7 @@ stories.add('basic', () => (
|
||||||
</>
|
</>
|
||||||
));
|
));
|
||||||
|
|
||||||
const ThemeStory = ({ theme }) => (
|
const ThemeStory = ({ theme }: { theme: string }) => (
|
||||||
<ThemeContext.Provider value={{ theme }}>
|
<ThemeContext.Provider value={{ theme }}>
|
||||||
<ScrollView style={{ backgroundColor: themes[theme].backgroundColor }}>
|
<ScrollView style={{ backgroundColor: themes[theme].backgroundColor }}>
|
||||||
<LoadMore load={load} type={MESSAGE_TYPE_LOAD_PREVIOUS_CHUNK} />
|
<LoadMore load={load} type={MESSAGE_TYPE_LOAD_PREVIOUS_CHUNK} />
|
|
@ -1,6 +1,5 @@
|
||||||
import React, { useCallback, useEffect, useState } from 'react';
|
import React, { useCallback, useEffect, useState } from 'react';
|
||||||
import { ActivityIndicator, StyleSheet, Text } from 'react-native';
|
import { ActivityIndicator, StyleSheet, Text } from 'react-native';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
|
|
||||||
import { themes } from '../../../constants/colors';
|
import { themes } from '../../../constants/colors';
|
||||||
import { MESSAGE_TYPE_LOAD_NEXT_CHUNK, MESSAGE_TYPE_LOAD_PREVIOUS_CHUNK } from '../../../constants/messageTypeLoad';
|
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 { theme } = useTheme();
|
||||||
const [loading, setLoading] = useState(false);
|
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;
|
export default LoadMore;
|
Loading…
Reference in New Issue