'How to force re render when an array changes its value in ReactJS

How to force re-render when an array changes its value in ReactJS.

I have an array like

const [providers, setProviders] = useState<Array<any>>(props.filters?.providers!);

and when I call a delete function to remove one element of this array the view doesn't render.

let OnDelete = (prop: any, func: any, p: IFilter) => {
    const index = prop.findIndex((x: IFilter) => x.code == p.code);
    if (index !== -1) {
        prop.splice(index, 1);
    }
    func(prop);
};


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source