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

How can I access the component instance inside the tab? #220

Open
Wandering-Li opened this issue Sep 28, 2023 · 0 comments
Open

How can I access the component instance inside the tab? #220

Wandering-Li opened this issue Sep 28, 2023 · 0 comments

Comments

@Wandering-Li
Copy link

Wandering-Li commented Sep 28, 2023

Hi,everyone. I'm a newcomer in React. In my development using rc-dock, the main issue is that it's hard for me to access the component instance inside a tab. For example I want to call the component's method or change its state from outside (outside the tab and dock layout.)

take the demo "controlled-layout" for example.


let tab0 = {
  title: 'Controlled Layout',
  content: (
    <div>
      <p>When you use <b>layout</b> instead of <b>defaultLayout</b> on &lt;DockLayout&gt;</p>
      <p>DockLayout will work as a controlled component</p>
    </div>
  )
};

in this demo we define the content in tab0 in this way.

let's say I import a custom component and add it to tab0, it becames:

import {CustomComponent} from "./select";
//other code
let tab0 = {
  title: 'Controlled Layout',
  content: (
    <div>
      <p>When you use <b>layout</b> instead of <b>defaultLayout</b> on &lt;DockLayout&gt;</p>
      <p>DockLayout will work as a controlled component</p>
      <CustomComponent></CustomComponent>
    </div>

  )
};

what should I do if I want to get the instance "CustomComponent" that in tab0?

in the demo, the" render(){return()}" part only have<DockLayout >

I tried to use ref but don't know how to use it with rc-dock.

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

No branches or pull requests

1 participant