如何将变量传递给已经具有变量的功能组件?
我在这里有一个孩子功能组件(Commafunc(e)),必须使用事件变量来调用以进行进一步处理,现在我需要做的事情,我似乎无法做到的,是返回在此处声明的变量之一commafunc子组件(realOutput)到addCommatonumber父零件(也许是props?),
我称之为parent
export default class home extends Component {
render() {
return (
<AddCommaToNumber />
)
}
}
the parent component:parent component(addcommatonumber.js),我称之为子component:child component:
function AddCommaToNumber() {
const [value, setValue] = React.useState("");
return (
<div>
<input
value={value}
onChange={(e) => { CommaFunc(e); setValue(e.target.value); }}
type="text"
/>
</div>
);
}
child component:child component:the child component(commafunc.js): (我需要以某种方式将此RealOutput
传递给AddCommatonumber组件)
export default function(e) {
let realOutput = 100;
}
任何提示或帮助都将不胜感激!
I have a child functional component here(CommaFunc(e)) which has to be called with a variable of event for further processing, now what I need to do and I seem to can't, is return one of the variables declared in the CommaFunc child component(realOutput) to the AddCommaToNumber parent component (maybe as props?)
Where I called the parent component:
export default class home extends Component {
render() {
return (
<AddCommaToNumber />
)
}
}
The parent component(AddCommaToNumber.js), and where I called the child component:
function AddCommaToNumber() {
const [value, setValue] = React.useState("");
return (
<div>
<input
value={value}
onChange={(e) => { CommaFunc(e); setValue(e.target.value); }}
type="text"
/>
</div>
);
}
The child component(commaFunc.js): (I need to somehow pass this realOutput
to the AddCommaToNumber component)
export default function(e) {
let realOutput = 100;
}
Any hints or help is appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论