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!: FiberProvider for stable reference in useFiber #10

Merged
merged 6 commits into from
Sep 21, 2022

Conversation

CodyJasonBennett
Copy link
Member

@CodyJasonBennett CodyJasonBennett commented Sep 21, 2022

Implements a <FiberProvider /> component that binds calls to useFiber to the React Fiber tree. This ensures that components get a stable reference to their respective Fiber regardless of their environment.

Note: pmndrs renderers like react-three-fiber implement this internally to make use of useContextBridge, so you would only need this when using hooks inside of react-dom or react-native.

import * as ReactDOM from 'react-dom/client'
import { FiberProvider } from 'its-fine'

function App() {
  const fiber = useFiber()
}

createRoot(document.getElementById('root')!).render(
  <FiberProvider>
    <App />
  </FiberProvider>,
)

@CodyJasonBennett CodyJasonBennett changed the title feat: FiberProvider for stable reference in useFiber feat!: FiberProvider for stable reference in useFiber Sep 21, 2022
@CodyJasonBennett CodyJasonBennett merged commit d0764fa into main Sep 21, 2022
@CodyJasonBennett CodyJasonBennett deleted the feat/fiber-provider branch September 21, 2022 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant