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

Export logic for determining whether the prompt should be shown #67

Open
Mesoptier opened this issue Jan 14, 2021 · 1 comment
Open

Comments

@Mesoptier
Copy link

If this logic is exported, developers can implement code-splitting for this component and thus avoid loading any additional data (the prompt, icons, and styles) unless it is actually needed.

For example:

import React, { Suspense } from 'react';
import { shouldShowPrompt } from 'react-ios-pwa-prompt';

const LazyPWAPrompt = React.lazy(() => import('react-ios-pwa-prompt'));

function App() {
    const options = {
        timesToShow: 1,
        promptOnVisit: 2,
    };

    return (
        <>
            {shouldShowPrompt(options) && (
                <Suspense fallback={null}>
                    <LazyPWAPrompt {...options} />
                </Suspense>
            )}
        </>
    );
}

@chrisdancee If this sounds like a good idea, I'll open a PR!

@chrisdancee
Copy link
Owner

Sounds like a great idea!
Feel free to drop a PR and I'll get straight onto reviewing it :)

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

No branches or pull requests

2 participants