Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

reactjs .net pass value to react

Since react is compilled into javacsript you can define your variable in your view.

<script type="text/javascript">let modelProperty= '@Model.ModelProperty';</script>
<script src="@Url.Content("~/Scripts/myComponent.jsx")"></script>

Then inside your react just call it like this

ReactDOM.render(<MyComponent prop0={modelProperty} />, document.getElementById("yourTargetElementId"))
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #reactjs #pass #react
ADD COMMENT
Topic
Name
2+7 =