I am using ReactJS.net to render react server side
Below is the code in my cshtml file
@Html.ReactRouter("RootComponent", new {services="service" }, containerId: "containerID")
Here i need to pass services to the child component. I have also declared the object in my entry point file
import service from '../../src/components/service.jsx';
global.service = service ;
Is there a way to access that object
Should it be = instead of : ?
@Html.ReactRouter("RootComponent", new {services = "service" }, containerId: "containerID")
The written above means that in your RootComponent
you will be able to access services
in it's props
.
So, it will be something like
class RootComponent extends React.PureComponent {
// ...
render () {
const { services } = this.props;
// ...
}
}
or
function RootComponent ({ services }) {
// ...
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.