Giter Site home page Giter Site logo

alexzajac / react-native-skeleton-content Goto Github PK

View Code? Open in Web Editor NEW
578.0 5.0 134.0 6.95 MB

A customizable skeleton-like loading placeholder for react native projects using expo.

Home Page: https://www.npmjs.com/package/react-native-skeleton-content

License: MIT License

TypeScript 99.50% JavaScript 0.50%
react-native component loader skeleton animation

react-native-skeleton-content's Introduction

React Native Skeleton Content

If you are not using expo, please head up to this page instead.

React native Skeleton Content, a simple yet fully customizable component made to achieve loading animation in a Skeleton-style. Works in both iOS and Android.

New Features

  • The package has been rewritten to Hooks and is using the declarative react-native-reanimated package for animations
  • It now supports nested layouts for children bones, see an example on this snack
  • It finally supports percentages dimensions for bones, for any type of animation!

Build Status Coverage Status npm version

Installation

npm install react-native-skeleton-content

Usage

  1. Import react-native-skeleton-content:
import SkeletonContent from 'react-native-skeleton-content';
  1. Once you create the SkeletonContent, you have two options:
  • Child Layout : The component will figure out the layout of its bones with the dimensions of its direct children.
  • Custom Layout : You provide a prop layout to the component specifying the size of the bones (see the Examples section below). Below is an example with a custom layout. A key prop for each child is optional but highly recommended.
export default function Placeholder() {
  return (
    <SkeletonContent
      containerStyle={{ flex: 1, width: 300 }}
      isLoading={false}
      layout={[
        { key: 'someId', width: 220, height: 20, marginBottom: 6 },
        { key: 'someOtherId', width: 180, height: 20, marginBottom: 6 }
      ]}
    >
      <Text style={styles.normalText}>Your content</Text>
      <Text style={styles.bigText}>Other content</Text>
    </SkeletonContent>
  );
}
  1. Then simply sync the prop isLoading to your state to show/hide the SkeletonContent when the assets/data are available to the user.
export default function Placeholder () {
  const [loading, setLoading] = useState(true);
  return (
    <SkeletonContent
       containerStyle={{flex: 1, width: 300}}
        isLoading={isLoading}>
        {...otherProps}
    />
  )
}

Props

Name Type Default Description
isLoading bool required Shows the Skeleton bones when true
layout array of objects [] A custom layout for the Skeleton bones
duration number 1200 ms Duration of one cycle of animation
containerStyle object flex: 1 The style applied to the View containing the bones
easing Easing bezier(0.5, 0, 0.25, 1) Easing of the bones animation
animationType string "shiver" The animation to be used for animating the bones (see demos below)
animationDirection string "horizontalRight" Used only for shiver animation, describes the direction and end-point (ex: horizontalRight goes on the x-axis from left to right)
boneColor string "#E1E9EE" Color of the bones
highlightColor string "#F2F8FC" Color of the highlight of the bones

Note: The Easing type function is the one provided by react-native-reanimated, so if you want to change the default you will have to install it as a dependency.

Examples

See the playground section to experiment : 1 - Changing the direction of the animation (animationDirection prop) :

export default function Placeholder () {
  return (
    <SkeletonContent
        containerStyle={{flex: 1, width: 300}}
        animationDirection="horizontalLeft"
        isLoading={true}>
        ...
    />
  )
}

2 - Changing the colors and switching to "pulse" animation (boneColor, highlightColor and animationType prop) :

export default function Placeholder () {
  return (
    <SkeletonContent
        containerStyle={{flex: 1, width: 300}}
        boneColor="#121212"
        highlightColor="#333333"
        animationType="pulse"
        isLoading={true}>
        ...
    />
  )
}

3 - Customizing the layout of the bones (layout prop) :

export default function Placeholder () {
  return (
    <SkeletonContent
        containerStyle={{flex: 1, width: 300}}
        animationDirection="horizontalLeft"
        layout={[
        // long line
        { width: 220, height: 20, marginBottom: 6 },
        // short line
        { width: 180, height: 20, marginBottom: 6 },
        ...
        ]}
        isLoading={true}>
        ...
    />
  )
}

Playground

You can test out the features and different props easily on Snack. Don't hesitate to take contact if anything is unclear !

react-native-skeleton-content's People

Contributors

0xjocke avatar adelbeke avatar alexzajac avatar armoniaechaos avatar dependabot[bot] avatar etuchscherer avatar exorth98 avatar ianmartorell avatar khevamann avatar luisflorido avatar mngyuan avatar nandorojo avatar valentinh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

react-native-skeleton-content's Issues

Each child in a list should have a unique "key" prop

Simply doing this, returns the unique key warning.
Any idea how to get rid of this warning?

<SkeletonContent isLoading={true} layout={[ { width: 10, height: 10 } ]} />

I like what is rendered though. Just dont want the warnings..

Doc about how to place a bone side to each other

Is your feature request related to a problem? Please describe.
I have take a look at docs and none on them shows easily how to place a bone side by side. All the bones I put inside the layout props are like block layout and break to next line get in a pile on top of eachother.

Describe the solution you'd like
Documentation must describe how to layout props works to create elements, then we could control how tey will be placed inside the skeletton

Describe alternatives you've considered
As layout receives an array objects. I have tryed nest objects with layout props

Unrecognize operator min


name: "Bug report \U0001F41B"
about: Create a report to help us improve
title: 'Got Unrecognize operator min '
labels: bug


Describe the bug
Unrecognize operator min

To Reproduce
Steps to reproduce the behavior:

  1. Import it on the project

Expected behavior

Screenshots
If applicable, add screenshots to help explain your problem.

Smartphone (please complete the following information):

  • Device: Iphone 7plus & Redmi note 8 pro
  • OS: ios 13

Additional context
i only import it not even used it on the components
both android and IOS got this error

App freezing when turning on debug with chrome

Describe the bug
Just turning on debug with chrome, then the app is freezing for both Platform OS without any error, all the buttons are not working and also can not scroll down the page until set the props "isLoading" to false.

To Reproduce
Steps to reproduce the behavior:

  1. Turning on debug with chrome

Expected behavior
Expect in debug and release mode, the animation will works fine and will not effect the app stability

Screenshots
https://user-images.githubusercontent.com/30230906/180195550-aad04db0-c203-44bf-8cb6-387713a4b587.mov
image

Smartphone (please complete the following information):

  • Device: iPhone13 Simulator , Samsung S22 Ultra
  • OS: IOS15.5, Android 12
  • Package version: "react-native-reanimated": "^2.4.1", "react-native-skeleton-content-nonexpo": "^1.0.13",
  • React Native Version : 0.67.3

Using it without expo project ?

Is somehow possible to use this without expo project because i am not using expo and it throwing below error after i installed expo module.

The Expo SDK requires Expo to run. It appears the native Expo modules are unavailable and this code is not running on Expo. Visit https://docs.expo.io to learn more about developing an Expo project.

Bezier node argument should be of type AnimatedNode, But got AnimatedOperator

Hi! Expo throw error

Captura de Pantalla 2020-06-28 a la(s) 12 46 02

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^1.2.29",
    "@fortawesome/free-regular-svg-icons": "^5.13.1",
    "@fortawesome/free-solid-svg-icons": "^5.13.1",
    "@fortawesome/react-native-fontawesome": "^0.2.5",
    "@ptomasroos/react-native-multi-slider": "^2.2.2",
    "@react-native-community/masked-view": "0.1.6",
    "@react-navigation/bottom-tabs": "^5.5.2",
    "@react-navigation/material-top-tabs": "^5.2.10",
    "@react-navigation/native": "^5.5.1",
    "@react-navigation/stack": "^5.5.1",
    "expo": "^37.0.12",
    "expo-linear-gradient": "~8.1.0",
    "react": "~16.9.0",
    "react-dom": "~16.9.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz",
    "react-native-gesture-handler": "~1.6.0",
    "react-native-gifted-chat": "^0.16.1",
    "react-native-iphone-x-helper": "^1.2.1",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-maps": "0.26.1",
    "react-native-maps-directions": "^1.8.0",
    "react-native-reanimated": "^1.9.0",
    "react-native-safe-area-context": "0.7.3",
    "react-native-screens": "~2.2.0",
    "react-native-skeleton-content": "^1.0.17",
    "react-native-svg": "11.0.1",
    "react-native-swiper": "^1.6.0",
    "react-native-tab-view": "^2.14.4",
    "react-native-web": "~0.11.7"
  },
  "devDependencies": {
    "@babel/core": "^7.8.6",
    "@babel/runtime": "^7.6.2",
    "@react-native-community/eslint-config": "^1.1.0",
    "@types/jest": "^25.2.3",
    "@types/react": "~16.9.23",
    "@types/react-native": "~0.61.17",
    "@types/react-test-renderer": "^16.9.2",
    "babel-jest": "^24.9.0",
    "babel-plugin-module-resolver": "^4.0.0",
    "babel-preset-expo": "~8.1.0",
    "eslint": "^7.3.1",
    "eslint-plugin-prettier": "^3.1.4",
    "husky": "^2.4.1",
    "jest": "^24.9.0",
    "jetifier": "^1.6.5",
    "lint-staged": "^8.2.1",
    "metro-react-native-babel-preset": "^0.58.0",
    "prettier": "^1.19.1",
    "react-test-renderer": "^16.11.0",
    "reactotron-react-native": "^3.7.1",
    "schedule": "^0.5.0",
    "typescript": "~3.8.3"
  },
  "private": true,
  "jest": {
    "preset": "react-native"
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "*.{js,json,md}": [
      "prettier --write",
      "git add"
    ]
  },
  "eslintConfig": {
    "extends": "@react-native-community"
  }
}

react-native-reanimated v3 drops support for code this package uses (fixed)

Describe the bug
react-native-reanimated dropped support for api v1 which this repo depended on. The fix I have provided is a modification of @phanghos's code in their issue for the nonexpo version of this package. I have patched this issue with patch-package for v1.0.28. I used this patch and some resolutions to fix the issue for myself.

Patch

Resolutions

  • "react-native-reanimated": "~3.3.0"
  • "expo-linear-gradient": "~12.3.0"
  • "react-native-redash": "^18.1.0

Here is the diff that fixed this problem for me
react-native-skeleton-content+1.0.28.patch

To Reproduce
You will run into the same problem upon upgrading to a newer version of the expo sdk. I am running this currently on expo sdk 49.

Expected behavior
Animations to play where they were previously working.

Smartphone (please complete the following information):

  • Device: SM-G991U1 (Galaxy S21 5G)
  • OS: Android v13, One UI v5.1
  • Package version: 1.0.28

Additional context
I understand that this issue may not be fixed with the info I provided for an indefinite period of time. The maintainer is predisposed so in the mean time I hope I have provided the information others may need so they will not have to jump through the same hoops I did. I definitely did learn a lot in the process. If you have any questions, I hope I will be able to answer in a timely matter.

Also it seems if you don't want to mess with patch-package to fix this. You may be able to use this package in the mean time until the pull request for the changes contained within @marcuzgabriel's are made. I'm not for sure if I tried their package previously but it may be more convenient for you than what I have given here.

please change the react-native-reanimated with latest version

the reanimated is not compatible

the Skeleton-content is clashing due to reanimated version miss-match

it is throwing errors like

interpolate() was renamed to interpolateNode() in Reanimated 2. Please use interpolateNode() instead
at node_modules/react-native-reanimated/src/reanimated2/interpolation.ts:119:4 in interpolate
at node_modules/react-native-skeleton-content/lib/SkeletonContent.js:174:30 in getGradientTransform
at node_modules/react-native-skeleton-content/lib/SkeletonContent.js:258:44 in getShiverBone
at [native code]:null in map
at node_modules/react-native-skeleton-content/lib/SkeletonContent.js:290:12 in SkeletonContent
at [native code]:null in performSyncWorkOnRoot
at [native code]:null in dispatchAction
at components/Main.tsx:150:16 in axios.then$argument_0
at [native code]:null in flushedQueue
at [native code]:null in callFunctionReturnFlushedQueue

Receiving two warnings when loading in Expo SDK 35

I'm getting the following warnings:
Warning: Invalid argument supplied to oneOfType. Expected an array of check functions
, but received string at index 0.

Warning: Each child in a list should have a unique "key" prop.%s%s See https://fb.me/
react-warning-keys for more information.%s,

Stack traces are below.

Warning: Invalid argument supplied to oneOfType. Expected an array of check functions
, but received string at index 0.

  • node_modules/expo/build/environment/muteWarnings.fx.js:27:24 in error
  • node_modules/prop-types/factoryWithTypeCheckers.js:23:20 in printWarning
  • node_modules/prop-types/factoryWithTypeCheckers.js:373:10 in createUnionTypeChecker
  • node_modules/react-native-skeleton-content/src/Skeleton/SkeletonContent.js:276:30 i
    n
  • node_modules/metro/src/lib/polyfills/require.js:331:6 in loadModuleImplementation
  • node_modules/react-native-skeleton-content/src/Skeleton/index.js:1:0 in
  • node_modules/metro/src/lib/polyfills/require.js:331:6 in loadModuleImplementation
  • node_modules/react-native-skeleton-content/src/index.js:1:0 in
  • node_modules/metro/src/lib/polyfills/require.js:331:6 in loadModuleImplementation
  • screens/ProfileScreen.js:6:0 in
  • node_modules/metro/src/lib/polyfills/require.js:331:6 in loadModuleImplementation
  • screens/Index.js:6:0 in
  • node_modules/metro/src/lib/polyfills/require.js:331:6 in loadModuleImplementation
  • navigator/TabNavigator.js:7:0 in
  • node_modules/metro/src/lib/polyfills/require.js:331:6 in loadModuleImplementation
  • navigator/AppNavigator.js:2:0 in
  • node_modules/metro/src/lib/polyfills/require.js:331:6 in loadModuleImplementation
  • App.js:4:0 in
  • node_modules/metro/src/lib/polyfills/require.js:331:6 in loadModuleImplementation
  • node_modules/expo/AppEntry.js:4:0 in
  • node_modules/metro/src/lib/polyfills/require.js:331:6 in loadModuleImplementation
  • node_modules/metro/src/lib/polyfills/require.js:197:45 in guardedLoadModule
  • null:null in global code

Warning: Each child in a list should have a unique "key" prop.%s%s See https://fb.me/
react-warning-keys for more information.%s,

Check the render method of SkeletonContent., ,
in View (at SkeletonContent.js:199)
in SkeletonContent (at ProfileScreen.js:60)
in RCTView (at View.js:45)
in View (created by Context.Consumer)
in StyledNativeComponent (created by Styled(View))
in Styled(View) (at ProfileScreen.js:129)
in ProfileScreen (created by Context.Consumer)
in Connect(ProfileScreen) (at SceneView.js:9)
in SceneView (at StackViewLayout.tsx:909)
in RCTView (at View.js:45)
in View (at createAnimatedComponent.js:151)
in AnimatedComponent (at StackViewCard.tsx:106)
in RCTView (at View.js:45)
in View (at createAnimatedComponent.js:151)
in AnimatedComponent (at screens.native.js:71)
in Screen (at StackViewCard.tsx:93)
in Card (at createPointerEventsContainer.tsx:95)
in Container (at StackViewLayout.tsx:984)
in RCTView (at View.js:45)
in View (at screens.native.js:101)
in ScreenContainer (at StackViewLayout.tsx:393)
in RCTView (at View.js:45)
in View (at createAnimatedComponent.js:151)
in AnimatedComponent (at StackViewLayout.tsx:383)
in PanGestureHandler (at StackViewLayout.tsx:376)
in StackViewLayout (at withOrientation.js:30)
in withOrientation (at StackView.tsx:104)
in RCTView (at View.js:45)
in View (at Transitioner.tsx:267)
in Transitioner (at StackView.tsx:41)
in StackView (at createNavigator.js:80)
in Navigator (at createKeyboardAwareNavigator.js:12)
in KeyboardAwareNavigator (at SceneView.js:9)
in SceneView (at createTabNavigator.tsx:67)
in RCTView (at View.js:45)
in View (at ResourceSavingScene.tsx:42)
in RCTView (at View.js:45)
in View (at ResourceSavingScene.tsx:26)
in ResourceSavingScene (at createBottomTabNavigator.tsx:157)
in RCTView (at View.js:45)
in View (at screens.native.js:101)
in ScreenContainer (at createBottomTabNavigator.tsx:147)
in RCTView (at View.js:45)
in View (at createBottomTabNavigator.tsx:146)
in TabNavigationView (at createTabNavigator.tsx:228)
in NavigationView (at createNavigator.js:80)
in Navigator (at createAppContainer.js:430)
in NavigationContainer (at App.js:10)
in Provider (at App.js:9)
in App (at withExpoRoot.js:20)
in RootErrorBoundary (at withExpoRoot.js:19)
in ExpoRootComponent (at renderApplication.js:35)
in RCTView (at View.js:45)
in View (at AppContainer.js:98)
in RCTView (at View.js:45)
in View (at AppContainer.js:115)
in AppContainer (at renderApplication.js:34)

  • node_modules/expo/build/environment/muteWarnings.fx.js:27:24 in error
  • ... 23 more stack frames from framework internals

Error message

Describe the bug
A clear and concise description of what the bug is.
I was hoping to use this skeleton for my react-native app, but I ran into an error message saying that the Animated node with ID 2 already exists. I am unsure what that is, I believe it might have something to do with react-native-reanimated.

Screenshots
image

Smartphone (please complete the following information):
System:
OS: Windows 10 10.0.19044
CPU: (8) x64 Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
Memory: 1.01 GB / 14.22 GB
Binaries:
Node: 14.18.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
npm: 9.1.1 - C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
Windows SDK:
AllowAllTrustedApps: Disabled
IDEs:
Android Studio: Not Found
Visual Studio: Not Found
Languages:
Java: 11.0.16.1 - C:\Program Files\Eclipse Adoptium\jdk-11.0.16.101-hotspot\bin\javac.EXE
npmPackages:
@react-native-community/cli: ^10.0.0 => 10.1.3
react: 18.1.0 => 18.1.0
react-native: ^0.70.4 => 0.70.6
react-native-windows: Not Found
npmGlobalPackages:
react-native: Not Found

Additional context
Add any other context about the problem here.

Expo SDK 43

This library not work with new expo SDK 43

Typescript getting error: Types of property 'flexDirection' are incompatible.

How do I get the types for creating the layout?

Type '{ flexDirection: string; marginRight: number; children: ({ width: number; height: number; borderRadius: number; marginVertical: number; padding: number; marginBottom?: undefined; } | { width: string; ... 4 more ...; padding?: undefined; })[]; }[]' is not assignable to type 'ICustomViewStyle[]'.
  Type '{ flexDirection: string; marginRight: number; children: ({ width: number; height: number; borderRadius: number; marginVertical: number; padding: number; marginBottom?: undefined; } | { width: string; ... 4 more ...; padding?: undefined; })[]; }' is not assignable to type 'ICustomViewStyle'.
    Types of property 'flexDirection' are incompatible.
      Type 'string' is not assignable to type '"column" | "row" | "row-reverse" | "column-reverse"'

[Feature Request] Skeleton Content Without Static Sizes

Are there any technical limitations surrounding skeleton content without static child sizes that are preventing such a feature? I want to start off by saying: I am aware that the documentation says that children must be statically sized to automatically create the bones.

I have updated the example snack: https://snack.expo.io/ryWqNy68L

with one text field with a static size and one with a dynamic size. One library that I use a lot in react web is react-skeleton-loader and this is what I'm drawing a comparison to. The library allows you to just wrap a regular component and it will just figure out the size based on the child. The other feature that I like (that I think would be much more achievable) is the element of randomness when displaying multiple lines.

I apologize for the lack of structure of this issue but I've been looking all over for an expo library that uses dynamic sizing but can't find one (and for that reason, I am assuming there must be a technical limitation in native that doesn't exist in dom)

The specific reason I am looking for dynamically sized skeletons is that I am worried that iOS's automatic scaling of text might be an issue if I am statically setting the text size.

Dependencies versions upgrade for Expo SDK 44

Upgrading expo projects to expo SDK 44 added some changes in dependencies versions :

  • expo-linear-gradient : 10.0.3 => 11.0.0
  • react-native-reanimated : 2.2.0 => 2.3.1

This induced some conflicts because of required dependencies of react-native-skeleton-content 1.0.24.

Is it possible to bump versions of these dependencies in a newer version of the package ?
That would be great :)

Incompatibility with Expo SDK 41

Describe the bug
After upgrading to Expo SDK 41, there is an error due to conflicting dependencies for expo-linear-gradient.

To Reproduce
Steps to reproduce the behavior:

  1. In an Expo Managed App using the react-native-skeleton-content components, follow the steps to upgrade outlined here.
  2. Load the app in an emulator, simulator or physical device.
  3. See error in terminal: "Invariant Violation: Tried to register two views with the same name ViewManagerAdapter_ExpoLinearGradient".
  4. See exception in app: "Tried to register two views with the same name ViewManagerAdapter_ExpoLinearGradient".

Expected behavior
The app should load without showing any errors.

Screenshots
react-native-skeleton-content

Smartphone (please complete the following information):

  • Device: Pixel 4 API 30 emulator
  • OS: [Android 11.0]
  • Package version [1.0.20]

Additional context
This can be solved by upgrading the expo-linear-gradient package in react-native-skeleton-content to version 9.1.0. As a workaround, apps can potentially downgrade expo-linear-gradient to version 8.4.0.

Animations don't play when loading but skeleton still shows

Describe the bug
Everything works as expected in our project until we introduce the loading state. The skeleton recognizes when the loading state changes and will display when it's supposed to but the animation won't trigger. I've sometimes been able to get it to start the animation by manipulating the code in a way to update the skeleton while not changing it's functionality. Or put simply, comment code and refresh it without some lines of code and then undo commenting and watch to see if the animation starts. This issue is also appearing on the snack linked for this package.

This is the snack for this package https://snack.expo.io/@ario99/skeleton-content-demo

Expected behavior
The animation should start when the skeleton is displayed.

Screenshots
image

Smartphone:

Device: Every device it seems.
OS: Web, iOS, and Android
Package version 1.0.17

Additional context
We have two separate pages we want to implement skeletons into. The layout of the skeleton is changed externally but even when we comment out the code for changing the layout it still has no animation. This started Monday (July 6th) and was working before hand. Considering there has been no updates to the package, I do not know why it is suddenly acting wrong.

Performance issue

🐛 Bug Report

Environment

Expo CLI 3.20.0 environment info:
    System:
      OS: macOS Mojave 10.14.6
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 12.16.1 - ~/.nvm/versions/node/v12.16.1/bin/node
      Yarn: 1.22.4 - ~/.nvm/versions/node/v12.16.1/bin/yarn
      npm: 6.13.4 - ~/.nvm/versions/node/v12.16.1/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    IDEs:
      Android Studio: 3.5 AI-191.8026.42.35.6010548
      Xcode: /undefined - /usr/bin/xcodebuild
    npmPackages:
      expo: ^37.0.8 => 37.0.8 
      react: 16.9.0 => 16.9.0 
      react-dom: 16.9.0 => 16.9.0 
      react-native: 0.61.4 => 0.61.4 
    npmGlobalPackages:
      expo-cli: 3.20.0

Steps to Reproduce

I'm displaying a list of 12 skeletons. I'm seeing significant performance degradation, even though there are no re-renders. I reviewed the expo gradient code and given that it's native, it does seem surprising, but it seems that the native gradient stuff sometimes actually renders very quickly and sometimes doesn't.

Screen Shot 2020-05-01 at 09 58 14

Screen Shot 2020-05-01 at 09 57 31

The code looks like this:

const PostSkeleton = () => {
	const width = Dimensions.get('window').width - 32;
	return (
		<Box pl={1} pb={1}>
			<Row>
				<Col xs={2}>
					<SkeletonContent
						containerStyle={{ width: 40 }}
						animationDirection="horizontalRight"
						layout={[{ width: 40, height: 40, marginBottom: 6 }]}
						isLoading
					/>
				</Col>
				<Col xs={10}>
					<SkeletonContent
						containerStyle={{ width: width - 66 }}
						animationDirection="horizontalRight"
						layout={[
							{
								width: width - 66,
								height: 16,
								marginBottom: 4,
							},
							{
								width: width - 80,
								height: 8,
								marginBottom: 4,
							},
							{
								width: width - 120,
								height: 8,
								marginBottom: 4,
							},
						]}
						isLoading
					/>
				</Col>
				<Col xs={12}>
					<SkeletonContent
						containerStyle={{ width }}
						animationDirection="horizontalLeft"
						layout={[
							{ width, height: 100, marginBottom: 6 },
							{ width, height: 10, marginBottom: 6 },
							{ width, height: 10, marginBottom: 6 },
							{ width: width - 60, height: 10, marginBottom: 6 },
						]}
						isLoading
					/>
				</Col>
			</Row>
		</Box>
	);
};

export default React.memo(PostSkeleton);

Expected Behavior

I would expect this to render very quickly given the native core.

Actual Behavior

It often seems to render quite slow.

How can I let the component figure out the layout by it's children.

So if I'm not wrong, there is two options to define layout.

  • Child Layout : The component will figure out the layout of its bones with the dimensions of its direct children.
  • Custom Layout : You provide a prop layout to the component specifying the size of the bones (see the Examples section below). Herunder is the example with a custom layout. A key prop for each child is optionnal but highly recommended.

So this is what I've tried.

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import SkeletonContent from 'react-native-skeleton-content';

export default function Placeholder() {
  return (
    <SkeletonContent
      containerStyle={{ flex: 1, width: 300 }}
      duration={1000}
      isLoading={true}>
      <View height={20} width={220} />
    </SkeletonContent>
  );
}

But the skeleton didn't show up.

Can you tell me if I'm wrong or something. Thanks
Snack: https://snack.expo.io/@nguyenvuzxc1/58a331

Feature: Support nested child layout, extract skeleton layout into components to reuse.

Is your feature request related to a problem? Please describe.
I want to reuse skeleton layout cause I don't want to repeat the loader in all of my project.

Describe the solution you'd like
Support nested child layout, allow us to extract skeleton layout into components, then reuse it.

Describe alternatives you've considered
No.

Additional context
For example I have a global loader file, name `Loader.tsx. It contains

import React from "react";
import { ViewStyle } from "react-native";
import SkeletonContent from "react-native-skeleton-content";

type LoaderProps = {
  children: React.ReactNode;
  containerStyle?: ViewStyle;
};

export default function Loader(props: LoaderProps) {
  const { children, containerStyle } = props;

  return (
    <SkeletonContent
      containerStyle={containerStyle}
      boneColor="#121212"
      highlightColor="#333333"
      animationType="pulse"
      isLoading={true}
    >
      {children}
    </SkeletonContent>
  );
}

Then I'll have a layout name VideoCardLayout.tsx, it contains:

import React from "react";
import { StyleSheet, View } from "react-native";
import {
  CardPaddingRight,
  CardWidth,
  ImageHeight,
  ImageRatio,
  StudiosFontSize,
  TitleFontSize,
} from "../components/VideoCard";

const VideoCardLayout = () => (
  <View style={styles.container}>
    <View style={styles.thumbnail} />
    <View style={styles.title} />
    <View style={styles.studios} />
  </View>
);

export default VideoCardLayout;

const styles = StyleSheet.create({
  container: {
    width: CardWidth,
    marginRight: CardPaddingRight,
    marginBottom: 5,
  },
  thumbnail: {
    width: CardWidth,
    height: ImageHeight * ImageRatio,
    marginBottom: 5,
  },
  title: {
    height: TitleFontSize,
    width: CardWidth * 0.7,
    marginBottom: 5,
  },
  studios: {
    height: StudiosFontSize,
    width: CardWidth * 0.4,
  },
});

Then if I want to use the layout, I just do this:

export default function HomeScreen() {
  const { data, isLoading, isError } = useHomePage();

  if (isLoading) {
    return (
      <Loader containerStyle={{ flex: 1, padding: 10 }}>
        <VideoCardLoader />
      </Loader>
    );
  }

  return (
    <ScrollView style={{ flex: 1, padding: 10 }}>
      {data.map((category: CategoryProps) => (
        <Category {...category} key={category.title} />
      ))}
    </ScrollView>
  );
}

Also, if I want to use VideoCardLayout to another layout, let say CategoryLayout, I'll do

import React from "react";

import { moderateScale } from "../utils/scale";

import { Dimensions, StyleSheet, View } from "react-native";
import VideoCardLoader from "./VideoCardLoader";
import VideoCardLayout from "./VideoCardLoader";

const { width: windowWidth } = Dimensions.get("window");

const CategoryLayout = () => (
  <View style={styles.container}>
    <View style={styles.categoryContainer}>
      <View style={styles.title} />
      <View style={styles.time} />
    </View>
    <View style={styles.videoContainer}>
      <VideoCardLayout />
    </View>
  </View>
);

export default CategoryLayout;

const styles = StyleSheet.create({
  container: {
    marginVertical: 10,
  },
  categoryContainer: {
    marginBottom: 10,
  },
  videoContainer: {
    flexDirection: "row",
    alignItems: "center",
  },
  title: {
    height: moderateScale(20),
    width: windowWidth * 0.7,
  },
  time: {
    height: moderateScale(16),
    width: windowWidth * 0.4,
  },
});

Upgrading project to Expo SDK 34 breaks SkeletonContent LinearGradient

Expo SDK 34 has removed the ability to import various modules from the 'expo' package as stated in the official release blog post (https://blog.expo.io/expo-sdk-34-is-now-available-4f7825239319?source=collection_home---6------0-----------------------):

In SDK 33, we deprecated imports from the monolith expo package in favor of installing and importing from individual module packages like expo-file-system. With SDK 34, we’ve fully removed the ability to import most modules from the expo package. This means that if you try to import { FileSystem } from 'expo';, you’ll now see an error instead of a warning.

After I upgraded a project that was using SDK 33 (version of deprecation of imports from 'expo' package) the SkeletonContent component broke.

To fix it I opened the SkeletonContent.js file inside my node_modules/react-native-skeleton-content/src/Skeleton folder and changed the LinearGradient import to import from 'expo-linear-gradient'.

Projects depending on updated expo-linear-gradient conflict with package lock

Describe the bug

Our project depends on [email protected], but this package-lock and published version of the package depends on ~8.3.0, causing a crash when both are loaded in react native.

To Reproduce
Steps to reproduce the behavior:

  1. Make a new expo typescript project
  2. Add expo-linear-gradient as a dependency
  3. Add react-native-skeleton-content as a dependency
  4. Make a View with react-native-skeleton-content and a gradient
  5. expo start and see a crash

Expected behavior
No crash

Screenshots

Smartphone (please complete the following information):

  • iPhone X
  • iOS 14
  • 1.0.20

Additional context

Remove React Native Reanimated 2 as direct dependency

Most time, apps are using React Navigation or another library that uses react-native-reanimated as a dependency.
Those libraries define their own Reanimated dependency version which does not match by version defined by react-native-skeleton-content which result in this issue - software-mansion/react-native-reanimated#1781

This should resolve by using yarn resolutions inside Expo Go and in production with expo build:android but fail with new EXPO EAS build.

By remove react-native-reanimated as direct dependency from here, developer will install react-native-reanimated version compatible with EXPO SDK by
using expo install react-native-reanimated and all libraries will use that version compatible with EXPO SDK.

Error on loading react-natie skeleton content package

I have started new project and implementing the react-native-skeleton-content lib..
When i imported this library getting the below issue

"The package /node_modules/react-native-skeleton-content/package.json was successfully found. However, this package itself specifies a main module field that could not be resolved (/node_modules/react-native-skeleton-content/lib/index.js). Indeed, none of these files exist:"

I am not sure how this should be fixed. Please help me out to fix this please

Versions:

"expo": "^33.0.0",
"react": "16.8.3",
"react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz",

Lib doesn't work on RN 0.72

We have been using this lib for quite a while for our React Native application but since we updated our app version to 0.72 two weeks ago, we can't make the lib work, getting multiple errors on this lib, like "Property 'loadingValue' doesn't exist",
"something with the belzier function doesn't exist also", etc.

Anyone went through this and have a hint on how to fix it?

Expo SDK 39 bug: Invariant Violation

Describe the bug
After upgrading my expo app to SDK 39 this package stopped working at all.
In-app error-log shows message: "Malfored JS ..." and strange numbers after it, but console gives more information - you can find full stack trace below:
https://pastebin.pl/view/4add7ece

To Reproduce
Steps to reproduce the behavior:

  1. Create stock new Expo SDK 39 app
  2. Follow guide from package homepage to create skeleton.
  3. Launch app and see error when navigated to skeleton.

Expected behavior
Package works also on Expo SDK 39.

Screenshots
If applicable, add screenshots to help explain your problem.

Smartphone (please complete the following information):

Additional context
Note that i am not using Reanimated v2, still waiting for stable release.

ColorProptype removed from expo-linear-gradient -> erroring

Describe the bug
node_modules/expo-linear-gradient/build/LinearGradient.js
Module not found: Can't resolve 'react-native-web/dist/exports/ColorPropType' in '.../node_modules/expo-linear-gradient/build'

To Reproduce

  • make an app with skeleton on expo 38.
  • Open app in web browser
  • upgrade to expo 39
  • broken

Expected behavior
It shouldn't error. The depenency to expo-linear-gradient "^8.0.0" should not expect propTypes?

Additional context
Was working fine before upgrade to expo 39

flatlist data not showing inside <SkeletonContent>

Describe the bug
i am fetching some data from api and showing inside the flatlist ...i have use <SkeletonContent to show loading indicator until we didn't get api response..but after getting the api response i am setting isloding value as false.but flatlist not rendering inside its showing nothing on screen

To Reproduce
Steps to reproduce the behavior:

take one
2.inside that add flatlist to show some data
check result
Expected behavior
expecting flatlist that showing api data after setting isloding value as false

Device:]android/ios any
OS: any
PAckage version:1.0.13

Additional context
<SkeletonContent
containerStyle={{flex: 1, width: '100%'}}
isLoading={spinner}
layout={[
{key: 'someId', width: 320, height: 20, marginBottom: 6},
{key: 'someOther', width: 380, height: 20, marginBottom: 6},
{key: 'someOtherId', width: 380, height: 30, marginBottom: 6},
]}>
<FlatList
nestedScrollEnabled={true}
style={{flex: 1}}
data={data.data}
renderItem={renderItem}
horizontal={true}
keyExtractor={item => '' + item.pId}
contentContainerStyle={{
flexGrow: 1,
}}
ListFooterComponentStyle={{marginHorizontal: 15}}
// scrollEnabled={true}
showsHorizontalScrollIndicator={true}
/>

flex layout without animation

image

Problem Description:
Three boxes in a row, with flex in the middle, There are animations on both sides, not in the middle

Code:
image

How to solve。 thanks

Expo SDK 43

Describe the bug
Hello Alex,

This error comes when we want to use the package with Expo SDK 43, have you the possibility to fix it ?

Unable to resolve module @unimodules/core from /Users/arthurdelbeke/work/ko-app-expo/node_modules/react-native-skeleton-content/node_modules/expo-linear-gradient/build/NativeLinearGradient.ios.js: @unimodules/core could not be found within the project or in these directories:
  node_modules/react-native-skeleton-content/node_modules
  node_modules

If you are sure the module exists, try these steps:
 1. Clear watchman watches: watchman watch-del-all
 2. Delete node_modules and run yarn install
 3. Reset Metro's cache: yarn start --reset-cache
 4. Remove the cache: rm -rf /tmp/metro-*
> 1 | import { requireNativeViewManager } from '@unimodules/core';
    |                                           ^
  2 | const NativeLinearGradient = requireNativeViewManager('ExpoLinearGradient');
  3 | export default NativeLinearGradient;
  4 | //# sourceMappingURL=NativeLinearGradient.ios.js.map

Excessive number of pending callbacks with Expo SDK 40

One I've upgraded from Expo SDK 37 to SDK 40, I started getting this error:

Warning: Please report: Excessive number of pending callbacks: 501. Some pending callbacks that might have leaked by never being called from native code

If I remove all references to <SkeletonContent /> in code, I do not get the above error anymore.
Could this be an issue related to react-native version? If so, what would a possible fix be?
Worth noting that on Android the error is different and related to multiple Animated IDs...

To Reproduce
Steps to reproduce the behavior:

  1. Create a sample Expo project with SDK 10
  2. Install latest react-native-skeleton-content package and add a few elements to your main component
  3. Running the app should give you this warning/error

Expected behavior
No error

Smartphone (please complete the following information):

  • Device: iPhone11
  • OS: iOS13.4
  • Package version: ^1.0.20

Invariant Violation Error

Describe the bug
When rendering the SkeletonContent component, I receive this error.
Invariant Violation: [228,{"type":"value","value":"<<NaN>>"}] is not usable as a native method argument

This error is also thrown prior to the one above
Error: Exception in HostFunction: Malformed calls from JS: field sizes are different. [...array of what I assume are module ids]

To Reproduce
Steps to reproduce the behavior:

  1. Install react-native-skeleton-content using expo install
  2. Render the component
  3. Observe the error

Expected behavior
The component renders with no errors

Smartphone:

  • iPhone XR
  • OS: iOS 15.0.2

Code

import { View, Text } from 'react-native'
import SkeletonContent from "react-native-skeleton-content";

export default function FeedLoading() {
    const MockPost = () => {
        return (
            <SkeletonContent isLoading={true}>

                <Text>
                    Your content
                </Text>

                <Text>
                    Other content
                </Text>

            </SkeletonContent>
        )
    }
    return (
        <View style={{ height: 100, width: "100%" }}>
            <MockPost />
        </View>
    )
}

Expo SDK 45

Describe the bug
This package throws an error when using with Expo SDK 45.

To Reproduce
Steps to reproduce the behavior:

  1. Import package in a project using Expo SDK 45
  2. Render component
  3. See error

Expected behavior
This should be compatible with Expo SDK 45.

Error
Error: Requiring module "node_modules/react-native-skeleton-content/lib/index.js", which threw an exception: TypeError: undefined is not an object (evaluating 'NativeUnimoduleProxy.viewManagersNames.includes')

Smartphone (please complete the following information):

  • Device: Iphone 12
  • OS: iOS 14
  • Package version 1.0.24

Tried to register two views with the same name ViewManagerAdapter_ExpoLinearGradient

thanks for this package, I am trying to use the package but I am getting an error of Tried to register two views with the same name ViewManagerAdapter_ExpoLinearGradient. I think its probably because I have Expo-Linear-Gradient version 6.0.0 installed (I am using Expo SDK 34.0.0). I checked the package in node modules and saw it had a Expo-Linear-Gradient version 7.0.1 in the dependencies. How can I go about this please. Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.