I'm new to react world and I have line like this:
<Button onClick={() => console.log("hello")}>Button</Button>
and on click you will get hello
printed on the console. Now change the line to:
<Button onClick={() => <NewComponent />}>Button</Button>
now on click on the button, I expect the NewComponent
to be rendered. But it doesn't.
I'm not sure, why that is the case. Note that I have the above code in the render
method.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…