1

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)enter image description here

1 Answer 1

2

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)

Sign up to request clarification or add additional context in comments.

3 Comments

Hi! Thanks for the reply! Tried to use it for react but didn't work. I see now that this is indeed the solution for vuejs. Do you have any experience with it? Is it better/easier than react?
Well, that's a impossible question to answer... because better is a difficult thing to define. I already worked with angular2 and vuejs, never with react and in my humble perspective I like vuejs more simply because it is super raw. Also, Laravel bundles vuejs with its own framework and that's why it's a good match, after all you get support out of the box.
Alright, then maybe it's time for me to check out vue.js. Thansk for the answer and your time @nullisnotundefined !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.