question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

export component's context hook

See original GitHub issue

Feature request

export component’s context

Overview

I creating theme props for accordion component and I can not get current component’s state for my custom Arrow component. For example, accordion component has useAccordionValueContext

Examples in other libraries

Who does this impact? Who is this for?

Advanced

Additional context

My example and my Arrow component image

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
andy-hookcommented, Nov 10, 2022

But it just a bit annoying to make the extra code every time I need that state.

Yeah I can understand your perspective here, as @benoitgrelard mentioned we want to limited the api surface but this can add additional complexity in some cases, especially if you then need to share this controlled value with other components e.g. in an open api design system.

Thanks for your feedback 🙏

1reaction
andy-hookcommented, Nov 9, 2022

@QzCurious The open state is already available to you via the controlled props:

https://codesandbox.io/s/tailwind-transition-6pwf41?file=/src/App.js

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using React context with a custom hook
Using React context with a custom hook. React Context is a great, builtin API for passing data from a parent component to any...
Read more >
Context - React
Context. Context provides a way to pass data through the component tree without having to pass props down manually at every level.
Read more >
How and When to Use Context in React with Hooks
Context allows you to pass data across any number of React components, regardless of nesting. Redux or Context? In a very small application,...
Read more >
An Example: Use Context and Hooks to share state between ...
We export the following three from this file: The Context This will be used by other components through the useContext Hook; The Provider:....
Read more >
React Context Provider Hook Pattern - NimbleWebDeveloper
React Context Provider Hook Pattern - Share Context via Custom Hook. ... import {createContext, useState} from React; export const SomeContext ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found