Title is likely wrong to the question. I'm asking, but here is my question. Not sure if this is possible:
I have 2 react components, say
import logo from './logo.svg';
import './App.css';
import Test from './components/Test.js'
function App() {
return (
<div className="App">
<header className="App-header">
<Test/>
</header>
</div>
);
}
export default App;
import logo from '../logo.svg';
function Test() {
const savePressed = () => {
console.log("hello")
}
return (
<div>
<img onClick={savePressed} src={logo}/>
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</div>
);
}
export default Test;
I know that I can render Test inside of App as shown, however, I was wondering if I could insert elements directly into Test from App like such shown below (<p> inside of <Test>):
import logo from './logo.svg';
import './App.css';
import Test from './components/Test.js'
function App() {
return (
<div className="App">
<header className="App-header">
<Test>
<p> hello </p>
</Test>
</header>
</div>
);
}
export default App;
if this is possible, how can it be accomplished? I am aware that this may be against convention (just use props/state to manage stuff like this,) but am curious nonetheless.