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

docs: remove 'import type' declaration in javascript snippet #9180

Merged
merged 1 commit into from
Jul 27, 2023

Conversation

oluwatobiss
Copy link
Contributor

@oluwatobiss oluwatobiss commented Jul 27, 2023

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

The import type {Location} from 'history' statement in the myClientModule.js snippet causes JavaScript to throw an error because an import type declaration works only in TypeScript files—not JavaScript.

So, I propose removing the declaration from the doc example to prevent confusing users.

- import type {Location} from 'history';

export function onRouteDidUpdate({location, previousLocation}) {
  // Don't execute if we are still on the same page; the lifecycle may be fired
  // because the hash changes (e.g. when navigating between headings)
  if (location.pathname !== previousLocation?.pathname) {
    const title = document.getElementsByTagName('h1')[0];
    if (title) {
      title.innerText += '❤️';
    }
  }
}

export function onRouteUpdate({location, previousLocation}) {
  if (location.pathname !== previousLocation?.pathname) {
    const progressBarTimeout = window.setTimeout(() => {
      nprogress.start();
    }, delay);
    return () => window.clearTimeout(progressBarTimeout);
  }
  return undefined;
}

Test Plan

N/A (This is a doc update)

Test links

Snippet's Doc Section: Client module lifecycles

Deploy preview: https://deploy-preview-9180--docusaurus-2.netlify.app/

Related issues/PRs

N/A

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jul 27, 2023
@netlify
Copy link

netlify bot commented Jul 27, 2023

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit 72715c9
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/64c2679fd44fc000072c2176
😎 Deploy Preview https://deploy-preview-9180--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions
Copy link

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 58 🟢 97 🟠 83 🟢 100 🟠 89 Report
/docs/installation 🟠 76 🟢 100 🟠 83 🟢 100 🟠 89 Report

@slorber slorber added the pr: documentation This PR works on the website or other text documents in the repo. label Jul 27, 2023
@slorber
Copy link
Collaborator

slorber commented Jul 27, 2023

Thanks 👍

@slorber slorber merged commit 983fb2d into facebook:main Jul 27, 2023
9 checks passed
@oluwatobiss oluwatobiss deleted the patch-2 branch July 27, 2023 13:58
slorber pushed a commit to VinceCYLiao/docusaurus that referenced this pull request Aug 3, 2023
This was referenced Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: documentation This PR works on the website or other text documents in the repo.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants