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] Fix layout shift example page #4350

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented Nov 1, 2024

@oliviertassinari oliviertassinari added docs Improvements or additions to the documentation bug 🐛 Something doesn't work labels Nov 1, 2024
@bharatkashyap
Copy link
Member

I can see this still on the PR preview link:

layoutShift.mov

@oliviertassinari
Copy link
Member Author

layoutShift.mov

@bharatkashyap This is another issue, it's a problem with how docs-infra loads the font.

Here the PR fixes the setState:

Screen.Recording.2024-11-03.at.17.28.05.mov

importExamples();
}, [examplesFile]);
// @ts-ignore
const req = require.context('./', false);
Copy link
Member

@Janpot Janpot Nov 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this will pull the whole folder (including files we don't need such as this source file) in the bundle. I'd prefer to just import them statically instead of doing proprietary webpack stuff. It also makes it type safe automatically.

import coreExamples from './core-examples'
import studioExamples from './studio-examples'

const EXAMPLES_BY_PRODUCT = {
  'core-examples': coreExamples,
  'studio-examples': studioExamples
}

// ...

const examples = EXAMPLES_BY_PRODUCT[examplesFile]

Or better yet, avoid the indirection, just pass the array as a prop and import the correct file on the callsite.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work docs Improvements or additions to the documentation PR: out-of-date The pull request has merge conflicts and can't be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants