Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate head side effects to hooks (#37526)
* rewrite head side effects component in hooks * remove mapping from element to children in head manager since they're already the children of `<Head>` When move `SideEffect` to hooks, the effects scheduling is earlier than life cycle. We're leverage layout effects and effects at the same time, always cache the latest head updating function in head manager in layout effects, and flush them in the effects. This could help get rid of the promises delaying approach in head manager. Co-authored-by: Shu Ding <3676859+shuding@users.noreply.github.com>
- Loading branch information
Showing
7 changed files
with
134 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Head from 'next/head' | ||
import React from 'react' | ||
|
||
function Foo() { | ||
const [displayed, toggle] = React.useState(true) | ||
|
||
return ( | ||
<> | ||
{displayed ? ( | ||
<Head> | ||
<title>B</title> | ||
</Head> | ||
) : null} | ||
<button onClick={() => toggle(!displayed)}>toggle</button> | ||
</> | ||
) | ||
} | ||
|
||
export default () => { | ||
return ( | ||
<> | ||
<Head> | ||
<title>A</title> | ||
</Head> | ||
<Foo /> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters