English 中文(简体)
无法将职能传给康复中的儿童部分
原标题:Not able to pass function to child component in React

I don t understand what is happening, the syntax seems to be right, but I m receiving this error:

类型:选择职业不是功能

// PARENT COMPONENT

import React, { useState } from  react 


export default function LayoutMain(props) {

    const [message, setMessage] = useState("Hello World");

    const chooseMessage = (message) => {
        setMessage(message);
    };


    return (
        
        <div>
            <LayoutMenu>
                 <Navigator chooseMessage={chooseMessage} />
            </LayoutMenu>
        </div>
    )
}



//CHILDREN COMPONENT

export default function Navigator({chooseMessage}) {
   
    let msg =  Goodbye ;
    
    return (
  
            <div className= navigator-header  onClick={() => chooseMessage(msg)}>
                 test
            </div>
    )
}

我读过关于解除国家地位的文章,还观看了一些录像,并仔细地一再遵循指示,但没有成功。

#NEW UDPATE

我刚刚认识到,我的法典是绝对正确的,它必须是与汇编者有关的东西。

问题回答

象《刑法》这样的种子正在做罚款。 然而,你可以控制所有逻辑,从能够成为父母控制者的一个部分,把方法作为推进剂,与他们互动,更容易管理那里的国家。

https://codesand Box.io/s/tender-smoke-57v1bk?file=/src/App.js”rel=“nofollow noreferer”>https://codesand Box.io/s/tender-smoke-57v1bk?file=/src/App.js

如果你想要在儿童中使用这种信息,你可以把母子的束缚下来。

export default function LayoutMain (props) {
    const [message, setMessage] = useState( Hello World );

    return (
        <div>
            <LayoutMenu>
                <Navigator setMessage={setMessage} />
            </LayoutMenu>
            <p>{ message }</p>
        </div>
    )
}

export default function Navigator({ setMessage }) {
    const chooseMessage = (message) => {
        setMessage(message);
    };
    
    return (
        <div className= navigator-header  onClick={() => chooseMessage( Goodbye )}>
            test
        </div>
    )
}

如果是这样的话,就会帮助他人...... 我被打上了类似的错误信息(几乎无法将功能传给康复中的儿童部分),但我感到我“一切照旧”。

我发现,在我的母阶级中,我制造了两种儿童类别的例子,在一种情况下,第一类儿童不需要,因此,NOT作为儿童组成部分的必要功能。 然而,这是我的问题的根源——一旦我纠正,错误就消失了。

(建议:你可以通过将父母的职能纳入所有儿童部分,或确保你在子女的部分进行某种检查,从而确定已经通过的职能并非绝对必要。)





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签