@ivalice/rn-placeholder
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

Build Status Coverage Status License: MIT

Display some placeholder stuff before rendering your text or media content in React Native.

Fully compatible with Expo and react-native-web.

Content

This is the content of the v2. If you're still using a version < 2, you should use this documentation instead.

Usage

Installation

$ yarn add rn-placeholder

In your code

This is a new API coming from v2. However, the v1 APIs are still available in components available

import Placeholder, { Line, Media } from "rn-placeholder";

const ComponentLoaded = () => <Text>I'm loaded!</Text>;

const MyComponent = () => {
  const [isReady, setReady] = useState(false);

  // your logic

  return (
    <Placeholder
      isReady={isReady}
      animation="fade"
      whenReadyRender={() => <ComponentLoaded />}
      renderLeft={() => <Media hasRadius />}
      renderRight={() => <Media />}
    >
      <Line width="70%" />
      <Line />
      <Line />
      <Line width="30%" />
    </Placeholder>
  );
};

When the value of isReady changes to something truthy, the ComponentLoaded will be rendered.

Package Sidebar

Install

npm i @ivalice/rn-placeholder

Weekly Downloads

2

Version

2.0.0

License

MIT

Unpacked Size

87.7 kB

Total Files

29

Last publish

Collaborators

  • ivalice