Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

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
You can’t perform that action at this time.