Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Followers 0
Login Register as User

React This State Variable undefined in Function

02.01.2023 (πŸ‘776)

In React, wenn man vom HTML Code aus eine javascript Function aufruft, bei welcher eine state-variable verwendet werden soll

Uncaught TypeError: Cannot read properties of undefined (reading 'state')



    onClickEdit(event) {

        window.location.href = "/edit/" + this.state.idarticle;



    //*arrow()-function to get id

    onClickEdit = (event) => {

        //alert('you clicked me');

        //event.preventDefault(); //stops a href=url

        window.location.href = "/edit/" + this.state.idarticle;



Aufruf aus dem Render() Block

<div style={{ float: 'right' }}>

<button type="button" className="btn btn-primary" onClick={this.onClickEdit }>Edit</button>


Ein Bild, das Text enthΓ€lt.

Automatisch generierte Beschreibung