score:0
if you need to show only one card the best way to keep state in the parent component.
for example
parentcomp ->
state: openedchapterid = someid
setopenedchapter(id) => setstate({openedchapterid: id});
so, when you try to render your children you can able to compare currentid.
<chapteractions isopened={chapterid === openedchapterid} handlemenuclick={() => setopenedchapter(chapterid)} />
Source: stackoverflow.com
Related Query
- How to update state of child component when it get called in map function from parent component React JS
- How to setState in child component when child function called from parent component in ReactJS
- How to avoid rerender all child components which in loop when parent component state update
- How to update parent state from child component in React + send a paramater
- Update parent state from child component and re-render this child when parent state is update
- How to update the correct state value in a parent component that gets its value from a child component using hooks in react?
- how to update parent's state from child component along with passing some information from child
- How to update redux state using a react variable passed up to the component from a child
- Child function not accessible when called from parent component through ref in React.js when placed in separate files
- In React, how can a parent component set state from the response an async fetch function performed in a child component?
- How to update parent's component using state from child component in React?
- How to update state of parent from child component in reactJS
- Not sure how to update parent state from the child component
- how to prevent child component from reload when the parent state is change
- How to update the state of child component from parent?
- How to update child state when button in parent component is clicked
- How can I set the state of my parent component from the child component when using react-router?
- How can I update state twice in a Parent component from a Child component?
- React : state is empty when trying to get it from child component
- How to get index number in child component when use map func in parent component
- How to update ancestor state from deeply nested child component without reducers
- How to get state variables from one component to another when i'm using history.push?
- How can I update my child component state from the parent class in React?
- How do I update state of a functional component from a class component in order to display items from a map in react
- How do I set state from a child component that requires a function to set state with react-dates?
- How to update a parent's component state from a child component in Reactjs
- How can I get when state change from other component
- React Parent Function Called from Child Component does not Update State?
- React hooks - update state from an input in a child component which is called on a button click
- react (class based) : How can I update JSON object in parent component using setState after the object being passed in function from child to parent?
More Query from same tag
- How to fix background gradiend on resize Chart.js / canvas
- Google OAuth Button Not Functioning
- Cannot get '/' route and 500 internal server error deploying MERN to AWS EC2
- Why isn't my react component's css updating dynamically?
- creating popup on click for tiny rich text editor
- How to make antd autocomplete update dropdown with server data each time input changes
- Make a new row when reach to 6 columns
- React - How can I pass API data from one component to another in a different js file?
- TypeError: Cannot read property 'version' of undefined
- Add an external html file with query strings in reactjs
- React Component State modified before setState called
- I'm trying to download a pdf file from a node server to a react client but when I open it, it shows blank
- Pass Callback function to child as props
- Material-UI: How to add border in TreeView
- Collapse an element based on input from a REST call
- How to get React-css-modules to work with external React UI libraries
- React JS: Differentiate between Click and Click + Shift event
- How do I override the defaultValues in useForm and maintain the isDirty function?
- Printing in JS page an array from React method in other file
- Using boolean values for <option> values in React
- how to trigger user-pilot(user on-boarding software) trigger function on click of a button in react js
- Should I store the access_token in localStorage+Redux or in axios defaults?
- How can i update fetch request in reactjs
- Typescript - ... has no compatible call signatures
- Why am I getting a 'no-unused-var' error when using in an inline function
- how to display variable value in HTML tag in react
- Why is my favicon not working in my next js app?
- How do I set custom fonts for header, body, and button tags for Material UI?
- Select Tag for React Updation , trying to display Default Value and Changed Values for Select Tag in React
- Authenticate Users and use Graph API using Azure AD, ReactJS and NodeJS