Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

send object from laravel to react js component

// Inside AppServiceProvider::boot
Blade::include('includes.react', 'react');

// Create a includes/react.blade.php file
<div id="rct-{{ $id }}" data-props='@json($props)'></div>

//Inside your views just include ($props must be an array)
@react(['id' => 'user-dropdown', 'props' => $props])

//Using this approach you can pass more complex data:
@react([
    'id' => 'user-dropdown',
    'props' => [
        'name' => Auth::user()->name,
        'obj' => [
            'bla' => ['id' => 1]
        ],
        'arr' => [1,2,3]
    ]
])
Comment

PREVIOUS NEXT
Code Example
Javascript :: repeat async call n times in js 
Javascript :: how to check alphabet case in javascript 
Javascript :: Play Audio Stream from Client 
Javascript :: nodejs export all mongodb collections 
Javascript :: ipcrenderer preload.js 
Javascript :: difference between var, let, const 
Javascript :: How to get maximum value in Javascript 
Javascript :: multer in express.js 
Javascript :: Delete a Cookie with JavaScript 
Javascript :: javascript object declaration 
Javascript :: crontab validate regex 
Javascript :: link externo no react 
Javascript :: how to log bodyparser error 
Javascript :: what is react mounting 
Javascript :: fabric js 
Javascript :: how to assert input value in testing library 
Javascript :: vue trigger function after certain time 
Javascript :: modulenamemapper not working 
Javascript :: get selected option from select javascript 
Javascript :: null is not an object clipboard rn 
Javascript :: dart how to convert json to x-www-form-urlencoded 
Javascript :: loop through async javascript -1 
Javascript :: mongoose encrypt database using mongoose encryption package 
Javascript :: if operator ternary 
Javascript :: formdata is empty after append in angular 
Javascript :: Century From Year 
Javascript :: javascript find area of triangle 
Javascript :: javascript how to convert string to number 
Javascript :: how to copy all elements in an array except for the first one in javascript 
Javascript :: js !! 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =