This is involving javascript using react. The problem is to pass 2 variables of data from a parent component to a child component. Pass these two variables to the child component: user1 = "[email protected]", user2 = "[email protected]".
-----------------Parent.js-----------------
import React from "react";
import ReactDOM from "react-dom";
import GuestApp from "./GuestApp";
class App extends React.Component {
constructor(props) {
super(props); // Must call
this.state = {role: "admin"};
}
render() {
switch (this.state.role) {
case 'guest':
return <GuestApp /* Insert the passing data in here */ />;
break;
}
}
}
ReactDOM.render(<App />,
document.getElementById("root"));
-----------------Child.js-----------------
import React from "react";
class GuestApp extends React.Component
{
constructor(props)
{
super(props); // Must call
this.state = {show: "home"};
}
render()
{
/* Insert any code here as needed to accept the passed down
information from parent.js */
}
}
Modify the parent and child files as needed to pass down
the information from parent to child. Need not worry about any
component rendering or anything else. This exercise is only to
correctly pass information down.
We can do this in multiple ways but here I have passed it down as a prop and the used it using object destructuring. My code is below.
This is the parent component
This is the child component.
I hope you liked it.
This is involving javascript using react. The problem is to pass 2 variables of data from...
This week we want to build an inheritance hierarchy using targets. You now need to take the Target class we have built and create a subclass that inherits from it. You can do whatever you want here, but it should be obvious how you changed the target. Some examples might include adding an additional ellipse to the target to increase the number of levels or changing up the colors. Once you have come up with one way to change the...
could you please help me with this problem, also I need a little text so I can understand how you solved the problem? import java.io.File; import java.util.Scanner; /** * This program lists the files in a directory specified by * the user. The user is asked to type in a directory name. * If the name entered by the user is not a directory, a * message is printed and the program ends. */ public class DirectoryList { public static...