I have the following component:
class MyComponent extends React.Component {
render() {
return ( <div>
<label>{this.props.myData.Count()}</label>
</div>
);
}
The idea being that the control displays a count of the data being passed in; here's what's currently in the Asp.Net View:
<div>
<MyComponent myData={@Model.MyData} />
</div>
I can see in the inspector that a value of myData has been passed to MyComponent, I also know that there is data inside of the MyData collection, but it isn't displaying anything.
I've also tried this:
@Html.React("MyComponent", new { myData = Model.MyData });
<div id="content">
<MyComponent />
</div>
But that doesn't render at all.
I can get the control to render by using the following format:
<div id="content">
</div>
<script src="@Url.Content("~/js/component.jsx")"></script>
But this doesn't allow me to pass data in.
Being quite new to React, I assume that I need to somehow tell the component to expect an object, or something similar. Could someone point me in the right direction, please?