reactjs - React Typescript object literal error -


i have component renders row of data , has delete button each row. clicking delete should change state using filter filter out clicked row. why error below.

i tried debugging use console.log , indeed getting correct row.id , rowid filter on, rows state not being reassigned.

interface tablesampleprops {     rows: any[]; }  interface tablesamplestate {     rows: any[]; }  export class tablesample extends react.component<tablesampleprops, tablesamplestate> {     constructor(props: tablesampleprops) {         super(props);          this.state = {            rows: this.props.rows.concat(),         };     }      public render() {         return <mytable rows={this.state.rows} ondeleterow={this.deleterow} />;     }      private deleterow = (rowid: number) => {         // console.log(rowid);         // this.state.rows.filter((row) => console.log(row.id !== rowid));         this.setstate = {             rows: this.state.rows.filter((row) => row.id !== rowid),          };     } } 

] error in ./src/ts/components/table-sample-tool.tsx [0] (57,13): error ts2322: type '{ rows: any[]; }' not assignable type '{ (f: (prevstate: tablesample state, props: tablesampleprops) => pick, ...'. [0] object literal may specify known properties, , 'rows' not exist in type '{ (f: (prevs tate: tablesamplestate, props: tablesampleprops) => pick, ...'. [0] child html-webpack-plugin "index.html": [0] chunk {0} index.html 542 kb [entry] [0]
+ 4 hidden modules [0] webpack: failed compile.

try using setstate({rows=... instead of setstate = {rows.... can this.state = {} in constructor setstate function.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -