score:0
Accepted answer
you need to set the boolean directly.
checked={setchecked(id)}
also in the setchecked function you can do the following modification. else when there is no matched elements it returns empty array which will still be true.
const setchecked = (ids) => boolean(bookmarksdata.find((e) => e.id === ids));
score:0
checked prop in checkbox component expects a boolean value, so you can do it like this
//the code in the loop where i display the posts
<checkbox
icon={<bookmarkbordericon />}
checkedicon={<bookmarkicon />}
checked={setchecked(id)}
onclick={() => savedbokmark({ id })}
/>
Source: stackoverflow.com
Related Query
- How can i persist with the state of a particular checkbox in filter button
- How do I control the checkbox with the filter?
- how to control the re-running with useEffect
- How to apply filter in a list with Checkbox in ReactJS?
- how do control the state for multiple component with one function
- How to filter the props for to render with ReactJS?
- How can I get the checkbox and label to line up in a form with React?
- How do I set the value of a checkbox with mobx-form?
- How can I add a checkbox to each element in the list and to be able to control it through state in my react app?
- How to filter the states object with a given value in react
- How to render the elements before to filter elements with ReactJS?
- How to create an array with the selected values from a checkbox list?
- How to filter data at firestore (firebase) and get the filtered data? How to use "equal to" with db collection?
- How to create multiple swiper instance in a react component and control one with the swipe of another?
- How to pass a parameter to a filter method & calling the function in React onClick event with different params?
- How to verify that the checkbox is checked with rc-forms package?
- How to show the state of a checkbox with used 'linkState' in reactjs?
- How to stop showing the checkbox in the input of Material UI TextField with select attribute when we have MenuItems with Checkboxes
- How to filter fetched data with checkbox in react hook
- How to compare nested array with the map or filter and only return with first match inside?
- How to filter and sort the same table data with React?
- How to Show and Hide with id when the checkbox is checked
- How will get the count using RestAPI with filter query
- How to display the checkbox label with link through label property in react?
- How to map the select control options with the certain type?
- How to to filter the same data with 2 search bars - ReactJS
- How to loop through an object with key and associated array and filter the array based on value presence in another array
- how to sync the antd multiple select table checkbox state with a select option
- how to filter the elements with muuri-react library
- With useEffect, how can I skip applying an effect upon the initial render?
More Query from same tag
- Cant fetch data from child component react
- Integrating Dispatch Actions in Container Component Pattern
- how to check if my checkbox is checked or not. Ad save it to LocalStorage
- NextJS 9.3 Link not a constructor function for JSX elements
- How to reset the form after submit or after clicking on cancel button using formik
- react-big-calendar import failing for css
- what's the difference between setCount(prev => prev + 1) and setCount(count + 1)?
- Error Router inside Router in React + Electron
- "no-unused-expressions" error in react with map function
- setting state based on conditional in reactjs
- Ignoring failed promises in Promoise.all
- Why alerts are not stopping?
- React - Navbar not showing and I am getting a Blank Screen
- cannot configure react-router to run on plunkr
- ant design progress bar. Using steps prevents full width
- React : can't type in autofocused input / keyboard selected input
- Should I use useMemo in hooks?
- react.js every nth item add opening tag or closing tag
- Unable to connect index.html in public folder with index.js in src folder
- Confused about execution order
- How do I set a links parent <li> to active in React?
- Checkbox update value only works on false to true, not on true to false, React, mongoDB
- What is the use of '& .MuiTextField-root' in { makeStyles } of Material UI?
- Swap values of two TextFields in Reactjs (material-ui)
- JSX Element type 'void' is not a constructor function for JSX elements
- Referencing DOM Elements with React Hooks
- How to make a progressbar with time data?
- How can i write React.js code in Visual Studio code?
- Cannot read property "temp" of undefined
- React with Flux: is this the dogmatic pattern or are there equal/better options?