Ok, I have a generic filters component which receives an index-filters component (set with properties in the index page) as a property. It will render it.
In the generic filters component, I have a method handleSingleFilter, which I need to pass to the index-filters component, but of course as the index-filters properties were set in the index page, it is not allowing me to update them.
In the index:
<IndexFilters
onSingleFilterChange={() => {
return
}}
/>
In the filters:
const { filters } = this.props
public handleSingleFilterChange = (filteredInfo: FilteredInfo) => {
this.state = {
filteredInfo
}
}
public render() {
filters.props.onSingleFilterChange = this.handleSingleFilterChange
return (
<div className={'filter-dropdown'}>
{filters}
</div>
)
}
I get the following error: filters.tsx:36 Uncaught TypeError: Cannot assign to read only property 'onSingleFilterChange' of object '#'
Is there a way to make the property writable?