Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add nested child layout, extract skeleton layout into components to reuse. #50

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

hoangvu12
Copy link

Hello there! 👋
This PR adds #49.

Warning
Child layout only supports View component only.

What does it means?
Now you can do:

import React from "react";
import { StyleSheet, View } from "react-native";
import SkeletonContent from "./lib/SkeletonContent";

const AvatarLayout = ({ size = 100 }: { size: number }) => (
  <SkeletonContent isLoading={true}>
    <View style={{ width: size, height: size, borderRadius: size / 2 }} />
  </SkeletonContent>
);

export default function App() {
  return (
    <View style={styles.container}>
      <SkeletonContent isLoading={true}>
        <View
          style={{
            flex: 1,
            flexDirection: "row",
            marginBottom: 10,
          }}
        >
          <AvatarLayout size={50} />
          <View style={{ alignSelf: "flex-start", padding: 10 }}>
            <View style={{ width: 100, height: 10 }} />
            <View style={{ width: 70, height: 20 }} />
            <View />
          </View>
        </View>
        <View style={{ width: 300, height: 250 }} />
      </SkeletonContent>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "black",
    padding: 10,
  },
});

This will return
image

This will let us separate skeleton layout into a different component, in SkeletonContent, instead of getting layout of that component and return the animation layout. It will return that component.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant