From c5d366e39f301f2c917b911db062da164060b775 Mon Sep 17 00:00:00 2001 From: Rohit Agrawal Date: Fri, 19 Nov 2021 18:54:59 +0530 Subject: [PATCH 1/2] fix(screen): fixed screen onPullToRefresh promise execution bug --- App.tsx | 18 +++--------------- src/components/Atoms/Screen/Screen.tsx | 8 ++++---- src/components/Atoms/Text/Text.tsx | 11 +++++------ storybook/storyLoader.js | 6 ++---- 4 files changed, 14 insertions(+), 29 deletions(-) diff --git a/App.tsx b/App.tsx index d99fc710..b1d4192c 100644 --- a/App.tsx +++ b/App.tsx @@ -14,6 +14,8 @@ import Screen from "./src/components/Atoms/Screen/Screen"; import Box from "./src/components/Atoms/Box/Box"; import Text from "./src/components/Atoms/Text/Text"; import Spinner from "./src/components/Atoms/Spinner/Spinner"; +import Center from "./src/components/Atoms/Center/Center"; +import Button from "./src/components/Molecules/Button/Button"; const App = () => { const [haveFontsLoaded] = useFonts({ @@ -25,23 +27,9 @@ const App = () => { "Poppins-ExtraBold": Poppins_800ExtraBold, }); - const [loading, setLoading] = useState(true); - - useEffect(() => { - setTimeout(() => { - setLoading(false); - }, 2000); - }, []); - return ( - + - {/* - - - {!loading && I am visible!} - - */} ); }; diff --git a/src/components/Atoms/Screen/Screen.tsx b/src/components/Atoms/Screen/Screen.tsx index 3faa4ba4..91ce5c4e 100644 --- a/src/components/Atoms/Screen/Screen.tsx +++ b/src/components/Atoms/Screen/Screen.tsx @@ -63,10 +63,12 @@ const Screen: React.FC = ({ variant: variant, }); + const { style, ...nativeProps } = props; + const onRefresh = React.useCallback(async () => { if (nativeProps.onPullToRefresh) { setRefreshing(true); - const functionValue = nativeProps.onPullToRefresh(); + const functionValue = await nativeProps.onPullToRefresh(); let isPromise = functionValue instanceof Promise; if (isPromise) Promise.resolve(functionValue).then(() => { @@ -76,9 +78,7 @@ const Screen: React.FC = ({ setRefreshing(false); } } - }, []); - - const { style, ...nativeProps } = props; + }, [nativeProps.onPullToRefresh]); return ( <> diff --git a/src/components/Atoms/Text/Text.tsx b/src/components/Atoms/Text/Text.tsx index 9b938679..7265480b 100644 --- a/src/components/Atoms/Text/Text.tsx +++ b/src/components/Atoms/Text/Text.tsx @@ -21,7 +21,7 @@ import { } from "../../../theme/src/styleFunctions"; import { StyleFunctionContainer } from "../../../theme/src/types"; -export type TextProps = ColorProps & +type TextStyleProps = ColorProps & BackgroundColorProps & OpacityProps & VisibleProps & @@ -46,16 +46,15 @@ export const textStyleFunctions = [ textShadow, ] as StyleFunctionContainer[]; -type RNTextProps = React.ComponentProps & { - children?: React.ReactNode; -}; +type RNTextProps = React.ComponentProps; -type ComponentProps = TextProps & Omit; +export type TextProps = TextStyleProps & + Omit; /** * Text is the component which controls the typography across your app. By default, it renders a component */ -const Text = React.forwardRef((props: ComponentProps, ref: any) => { +const Text = React.forwardRef((props: TextProps, ref: any) => { const componentSpecificProps = useAtomicComponentConfig( "Text", props, diff --git a/storybook/storyLoader.js b/storybook/storyLoader.js index cfc8f16c..2fd4a348 100644 --- a/storybook/storyLoader.js +++ b/storybook/storyLoader.js @@ -5,7 +5,6 @@ function loadStories() { require("../src/components/Atoms/Avatar/Avatar.story"); - require("../src/components/Molecules/Badge/Badge.story"); require("../src/components/Atoms/Box/Box.story"); require("../src/components/Atoms/Center/Center.story"); require("../src/components/Atoms/Divider/Divider.story"); @@ -15,18 +14,17 @@ function loadStories() { require("../src/components/Atoms/Spinner/Spinner.story"); require("../src/components/Atoms/Stack/Stack.story"); require("../src/components/Atoms/Text/Text.story"); + require("../src/components/Molecules/Badge/Badge.story"); require("../src/components/Molecules/Button/Button.story"); require("../src/components/Molecules/CheckBox/CheckBox.story"); require("../src/components/Molecules/Image/Image.story"); require("../src/components/Molecules/Input/Input.story"); - require("../src/components/Molecules/OfflineNotice/OfflineNotice.story"); require("../src/components/Molecules/Radio/Radio.story"); require("../src/components/Molecules/TextLink/TextLink.story"); } const stories = [ "../src/components/Atoms/Avatar/Avatar.story", - "../src/components/Atoms/Badge/Badge.story", "../src/components/Atoms/Box/Box.story", "../src/components/Atoms/Center/Center.story", "../src/components/Atoms/Divider/Divider.story", @@ -36,11 +34,11 @@ const stories = [ "../src/components/Atoms/Spinner/Spinner.story", "../src/components/Atoms/Stack/Stack.story", "../src/components/Atoms/Text/Text.story", + "../src/components/Molecules/Badge/Badge.story", "../src/components/Molecules/Button/Button.story", "../src/components/Molecules/CheckBox/CheckBox.story", "../src/components/Molecules/Image/Image.story", "../src/components/Molecules/Input/Input.story", - "../src/components/Molecules/OfflineNotice/OfflineNotice.story", "../src/components/Molecules/Radio/Radio.story", "../src/components/Molecules/TextLink/TextLink.story", ]; From e8e1e32eec895f1bd6152448a7733f4ecd0b6ae2 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 19 Nov 2021 13:31:17 +0000 Subject: [PATCH 2/2] chore(release): 1.6.2 [skip ci]nn## [1.6.2](https://github.com/agrawal-rohit/pearl-ui/compare/v1.6.1...v1.6.2) (2021-11-19) ### Bug Fixes * **screen:** fixed screen onPullToRefresh promise execution bug ([c5d366e](https://github.com/agrawal-rohit/pearl-ui/commit/c5d366e39f301f2c917b911db062da164060b775)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22405dfd..372e28fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [1.6.2](https://github.com/agrawal-rohit/pearl-ui/compare/v1.6.1...v1.6.2) (2021-11-19) + + +### Bug Fixes + +* **screen:** fixed screen onPullToRefresh promise execution bug ([c5d366e](https://github.com/agrawal-rohit/pearl-ui/commit/c5d366e39f301f2c917b911db062da164060b775)) + ## [1.6.1](https://github.com/agrawal-rohit/pearl-ui/compare/v1.6.0...v1.6.1) (2021-11-19) diff --git a/package.json b/package.json index be05a9a4..7b2d75b9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "main": "node_modules/expo/AppEntry.js", "name": "pearl-ui", - "version": "1.6.1", + "version": "1.6.2", "repository": "https://github.com/agrawal-rohit/pearl-ui.git", "license": "MIT", "private": false,