Answer the question
In order to leave comments, you need to log in
How to pass a component as a prop?
There is a task. Create an App2.js component and include it in App.js. Pass s3 (located in App) as a prop z1 inside App2. Display it on the page in App2 as props.
I can't figure out how to pass information from one component to another. Thanks everyone for the replies
Answer the question
In order to leave comments, you need to log in
app.js:
import React from "react";
import ReactDOM from "react-dom";
import App2 from "./App2";
const App = () => {
const s3 = "foo";
return <App2 z1={s3} />;
};
ReactDOM.render(<App />, document.getElementById("root"));
import React from "react";
const App2 = ({ z1 }) => {
return <div>{z1}</div>;
};
export default App2;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question