Skip to content

Instantly share code, notes, and snippets.

@peterpme
Last active April 27, 2018 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterpme/b7a9bada6a844213eab30d6539d5a1d5 to your computer and use it in GitHub Desktop.
Save peterpme/b7a9bada6a844213eab30d6539d5a1d5 to your computer and use it in GitHub Desktop.
withLoadingScreen First pass
import * as React from "react";
import { View, ActivityIndicator } from "react-native";
const withLoadingScreen = WrappedComponent => {
return class LoadingScreen extends React.PureComponent {
render() {
if (this.props.loading) return <ActivityIndicator size="small" color="white" />
return <WrappedComponent {...this.props} />;
}
};
};
export default withLoadingScreen;
@yanai101
Copy link

yanai101 commented Apr 27, 2018

if in render function it's not a good practice (for my opinion) do somthing like this (if you dont have state....):

import * as React from "react";
import { View, ActivityIndicator } from "react-native";

export default const withLoadingScreen = ({loading})=> ( loading ? : <WrappedComponent {...this.props} />);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment