score:0
try this:
function tabscomponant(props) {
const [itemone, setitemone] = usestate(false);
const [itemtwo, setitemtwo] = usestate(false);
return (
<div>
{itemone && <div classname="item1">item1 info</div>}
{itemtwo && <div classname="item2">item2 info</div>}
<button onclick={() => setitemone(!itemone)}>item 1</button>
<button onclick={() => setitemtwo(!itemtwo)}>item 2</button>
{itemone && <div classname="item1">item1 data</div>}
{itemtwo && <div classname="item2">item2 data</div>}
</div>
);
}
score:1
by searching online e.g. for "react tab component", you can find the following:
- https://www.digitalocean.com/community/tutorials/react-tabs-component
- https://blog.logrocket.com/how-to-build-tab-component-react/
by looking at these tutorials, you will find that you can usestate
to keep track of the currently active tab and change the state accordingly once one of your buttons gets pressed. depending on the state, you can then show or hide your other components.
Source: stackoverflow.com
Related Query
- How to make a Tab type simple component in React
- How make material UI Tab component auto Scrollable in react
- How do I make this React Core UI Tab Pane component work?
- How to make the whole Card component clickable in Material UI using React JS?
- how to make material data grid width to fill the parent component in react js
- How to make the GridList component in React Material-UI responsive
- How can I make a React "If" component that acts like a real "if" in Typescript?
- How do you correctly use React.lazy() in Typescript to import a react component with a generic type parameter?
- How to make AppBar component from material-ui-next react to scroll events
- How to make a React component setState() based on a Redux state change?
- How to make a React component fade in on scroll using IntersectionObserver, but only once?
- How to properly type a React ErrorBoundary class component in Typescript?
- How to make redirect inside component in React router?
- How do I make a React component editable?
- How to type a React component definition?
- How do I refresh my component when clicked on tab on bottomTabNavigator in React Native, in React Navigation v3?
- How to make svg react component imports from external module working with create-react-app?
- How to type a Typescript React Component that accepts a Context with a super-set of properties
- How to make cherry picking react component library like lodash & date/fns
- How to import a React proptypes typed component as type any into a React Typescript component
- How to make a React component look more readable and clean from my example?
- How to properly declare type for React wrapper component (HOC) using Typescript
- How to make React component wait for redux store variables to get set?
- How to type a React component that accepts another component as a prop, and all of that component's props?
- How to add type FunctionComponent to React functional component using the "function" syntax and not "const"?
- How to modify the wrapper css rule of a Tabs component to make the text aligned to the left in a vertical tab in Material-UI?
- Can TypeScript make React component instantiation type safe?
- React Ionic 5: How to pass object from App component to Tab component
- How can I make sure a React parent component loads data before its child component mounts?
- How to make my component re render after updating props from selector in react and redux-saga?
More Query from same tag
- Call react component's function from external JavaScript function
- how to update the url after saving a post
- Reactjs: On clicking title display blog post contents
- React Router - 404 page renders first on protected route
- How to get input textbox value in parent file from component in React Js
- How do I update a react.js component with a promise return ?
- Correct way to React axios post with UUID and nested object in JSON payload?
- Text exceeding maximum height and width of the container
- How do I pass in a component to a component in react js?
- Split string into separate line according to container size
- I am getting this error: “react-modal: App element is not defined”
- Unexpected token < when using reactjs app
- Meteor call method use the return value
- How to concate string outside loop using map() method in jsx?
- Passing html <img> components as a parameter property into <li> tags with react.js
- Use Django Static File in React Component
- How to bind one React Functional Component to another? (DevExtreme Chart to PivotGrid)
- How to reuse a Custom Material-ui button inside a react-app?
- What Format should FormData have?
- copyright is null, how do I make it so it runs after fully rendered?
- How to dispatch actions on location change with react router v4
- managing grouped buttons loading state within a map function
- How to create table with multiline cells in React-bootstrap?
- State is not getting updated
- when i use grid in react how can i align items to center 5 of 2
- Performance issue with cloud firestore
- How to use use-supercluster with Typescript
- How to color label on radio-button on react-materialize
- Inferences from JSX vs calling React Components as functions
- how can we replace span contenteditable in regex?