score:1
Accepted answer
you use useeffect
. the useeffect
's callback will be triggered when one of dependency is changed.
splice
function changes array in place (ie mutates the array). in this case your array variable (showfilter
) is not changed, therefore useeffect
's callback will not be triggered.
try using filter
function instead:
setfilter(showfilter.filter(el=> el !== id));
score:1
Source: stackoverflow.com
Related Query
- removing value from array not working NEXT.JS
- Add value from input into array is not working in React
- array.filter not removing value from array
- State not updating on removing value from array in React JSX funcntional component
- Removing Item from array in reducer not working
- Removing a value from an array using redux toolkit
- How to create array from state value and setstate after removing duplicates in reactjs
- array of selected values which I want to delete from state is not working as expected - React
- Push object from JSON rest api into empty array not working in React
- Add value from inputs to array if not exists
- array object working if we hardcode data but not working when we populate data from Node js to react js
- Update input value from state not working
- How to remove one item from an array using filter() in ReactJS - function not working properly
- Deleting component from array not working unless wrapped in div
- Loop through two array and based on condition change the property value not working
- why is sorting of array not working in reactjs even though it comes already sorted from backend?
- Removing item from an array of items does not work
- Get value from array couses "Property 'value' does not exist on type"
- React set value in array map not working
- React event target value from jsx element does not get bind to state and json array (Type error cannot read the properties of undefined )
- React refs created from Array not working
- Filter object from array where key "ID" == element.id not working
- Deleting an object from an array not working properly - React-dropzone
- How do I remove only one element from an array from Redux? Not working for me currently
- Removing an object from array with splice() does not work as expected in React
- Redux dispatch is not removing an item from the array
- React JS, Error is not defined no-undef when attempting to obtain first value from array
- React input value to array not working when using onClick
- Mapping data from yfinance array not working in React table
- forEach not working in ReactJs while using data from array
More Query from same tag
- Return function is called only once in NextJS web app
- Understanding React Router nested sub routes
- Fetching proper route path
- Use a ref to a DOM element both in parent and children components
- ReactJS - response in async call
- Having trouble getting checkboxes to programmatically reset with React Bootstrap
- Button cover image in carousel on small devices
- How to use css modules with create-react-app?
- Fractal Project Structure with React and Redux - pros/cons
- PptxGenJS add chart show nothing
- Toggle element data for element that I click on, not all elements
- Passing a function to React component in props
- The value of the object always shows "undefined" in React
- How to pass data as parameter in react-table?
- How to combine different input values (+react, typescript)
- How do I make react handler working for multiple values?
- How can I use create-react-app with Spring Boot?
- Trying to recursively render comments ReactJs
- How to render bootstrap grid from array with map in reactjs
- How to create multiple layouts in React?
- How to fire Marker component events programatically from another component
- React Redux Axios: POST Request not receiving credentials from redux state
- How to use react hook in Bubble chart using chart.js
- Material-UI Rating Component does not update star rating correctly
- React: Access Data from Redux in component
- React - Jest - Enzyme: How to mock ref properties
- How to check the class name of the event target in ReactJS?
- Request a React component to take action other than render
- Why React ref element.current returns null in React component using useRef hook?
- Update value after render