Reputation: 83
I don't know if this is even possible or maybe this is just a stupid question, but here it goes:
Is it possible to pass data from you Laravel controller to a React Component through a blade template?
I'm asking this because I have a form where I have three static form elements (name
, description
& deadline
) that are defined in blade and a dynamic part that adds elements (extra fields; name
, description
and type
for each extra field
) to the form on a button click.
I also want to use the component for editing, so I need to push data into it. My train of thought was to use React for the dynamic part so that I don't have to use native JS or jQuery to build this.
Note that I'm a beginner at React so I this point I don't even know if I'm doing it right/wrong. I've added a screenshot of the form to show illustrate what I mean. (sorry it's in Dutch but I've tried to add some notes to make it clear)
Upvotes: 1
Views: 1675
Reputation: 347
This maybe will help you out:
under Rendering json ..
This is how vuejs
works. Your controller would return a variable like $project
and you would pass it as a prop into your component by using @json($project)
Upvotes: 2