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 warning and crash in dev mode #20623

Merged
merged 1 commit into from
Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/pages/components/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ const requireRaw = require.context(
/\.(js|md|tsx)$/,
);

// Run styled-components ref logic
// https://github.com/styled-components/styled-components/pull/2998
requireDemo.keys().map(requireDemo);

// eslint-disable-next-line react/prop-types
export default function Page({ demos, docs }) {
return <MarkdownDocs demos={demos} docs={docs} requireDemo={requireDemo} />;
Expand Down
4 changes: 4 additions & 0 deletions docs/pages/guides/interoperability.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ const requireRaw = require.context(
/\.(js|md|tsx)$/,
);

// Run styled-components ref logic
Copy link
Member

Choose a reason for hiding this comment

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

what is "ref logic"?

Copy link
Member Author

Choose a reason for hiding this comment

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

They test that calling useRef crashes, however, we call it inside a React render method, hence, it warns.

Copy link
Member

Choose a reason for hiding this comment

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

So it's not about "ref logic" but rather about where we instantiate the module (they could use any hook. useRef is just the fasted). Doing it during render triggers a false alarm in styled-components.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, you are right

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, you are right

// https://github.com/styled-components/styled-components/pull/2998
requireDemo.keys().map(requireDemo);

// eslint-disable-next-line react/prop-types
export default function Page({ demos, docs }) {
return <MarkdownDocs demos={demos} docs={docs} requireDemo={requireDemo} />;
Expand Down
4 changes: 4 additions & 0 deletions docs/pages/styles/advanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ const requireRaw = require.context(
/\.(js|md|tsx)$/,
);

// Run styled-components ref logic
// https://github.com/styled-components/styled-components/pull/2998
requireDemo.keys().map(requireDemo);

// eslint-disable-next-line react/prop-types
export default function Page({ demos, docs }) {
return <MarkdownDocs demos={demos} docs={docs} requireDemo={requireDemo} />;
Expand Down
4 changes: 4 additions & 0 deletions docs/pages/system/basics.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ const requireRaw = require.context(
/\.(js|md|tsx)$/,
);

// Run styled-components ref logic
// https://github.com/styled-components/styled-components/pull/2998
requireDemo.keys().map(requireDemo);

// eslint-disable-next-line react/prop-types
export default function Page({ demos, docs }) {
return <MarkdownDocs demos={demos} docs={docs} requireDemo={requireDemo} />;
Expand Down