Jump to content
php.lv forumi
  • 0

React kļūda TypeError: is undefined


Wuu

Question

{this.state.c.map(function(k,i){
        this.state.ri.map(function(kk,ii){
            console.log(this.state.ri[ii].ID); <-- STRĀDĀ
            console.log(this.state.ri[k.id].ID); <-- STRĀDĀ
        }.bind(this));
        return    (<div key={i}>
                    <div className="row cells12">
                        <div className="cell">
                            <span className="mif-bookmark"></span>
                        </div>
                        <div className="cell colspan3">
                            {this.state.ri[k.id].ID} <-- NESTRĀDĀ
                        </div>
                    </div>
                 </div>);
}.bind(this))}

TypeError: this.state.ri[k.id] is undefined

 

A huļi?

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0
[{"ID":"18","item_id":"2","item_amount_stock":"5","item_amount_in_cart":"0","item_amount_preordered":"0","item_amount_sold":"0","item_timestamp":"2015-07-22 12:30:59","last_edit_timestamp":"2015-07-22 12:30:59","item_id_catalog":"prod2","item_name_catalog":"Spilvens","item_measurement_unit":"pcs"},{"ID":"12","item_id":"4","item_amount_stock":"25","item_amount_in_cart":"0","item_amount_preordered":"0","item_amount_sold":"0","item_timestamp":"2015-07-22 10:01:15","last_edit_timestamp":"2015-07-22 11:54:05","item_id_catalog":"prod3","item_name_catalog":"Desa","item_measurement_unit":"kg"}] 
0

JSON.parse(JSON.stringify(this.state.ri[0])) <-- NESTRADĀ "SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data"

 

JSON.stringify(this.state.ri[0]) <-- Strādā.

 

Nu wtf :)

Edited by Wuu
Link to comment
Share on other sites

  • 0

                        for (var i = 0; i < json[1].output.length; i++) {
                            json[1].output[i].edit = function() { 
                                console.log(json[1].output.ID);
                                this.props.handleMenu(this,'functions',new Event('post')); 
                            }.bind(this);
                        }

Atkal tas pats, json[1].output.ID eksistē, bet atgriezt nevar. Varbūt kāds izpalīdzēs?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...