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

feat: opt in insertion effect hook when available #753

Merged
merged 4 commits into from Oct 22, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/style.js
@@ -1,6 +1,7 @@
import { useLayoutEffect } from 'react'
import React from 'react'
import { useStyleRegistry } from './stylesheet-registry'
import { computeId } from './lib/hash'

export default function JSXStyle(props) {
const registry = useStyleRegistry()

Expand All @@ -14,7 +15,8 @@ export default function JSXStyle(props) {
return null
}

useLayoutEffect(() => {
const useDOMEffects = React.useInsertionEffect || React.useLayoutEffect
huozhi marked this conversation as resolved.
Show resolved Hide resolved
useDOMEffects(() => {
huozhi marked this conversation as resolved.
Show resolved Hide resolved
registry.add(props)
return () => {
registry.remove(props)
Expand Down