How to Add new Tab on Model. #441
Unanswered
pedrolucasfsouza
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
`
import {Layout, Model, Actions, TabNode, DockLocation} from 'flexlayout-react';
import 'flexlayout-react/style/light.css';
import {Container} from "@/components/Container";
import {Button} from "@/components/Button";
var json = {
global: {},
borders: [],
layout: {
type: "row",
weight: 100,
children: [
{
type: "tabset",
}
};
const model = Model.fromJson(json);
export default function Home() {
const factory = (node: TabNode) => {
var component = node.getComponent();
if (component === "button") {
return <Container className={'bg-red w-12 h-[500px]'}> ;
}
}
const addNewTab = () => {
console.log('823')
model.doAction(Actions.addNode(
{type:"tab", component:"button", name:"a grid", id:"5"},
"1", DockLocation.CENTER, 0));
}
);
}
`
I'm using React Hooks, but i have not been able to add new tabs on json document. I think that i didn't understeand well, can anyone give me help?
My main goal now is: add a new tab on click my button.
Beta Was this translation helpful? Give feedback.
All reactions