Randy_Johnson's avatar

Reactjs (Using Laravel assets in ReactJS). 💻💥🐒

Hi, I am connecting to a route of /dashboard/products and now this has become a problem because when using an image this is pushed onto the url. Is there anyone to use laravel helpers in reactjs inertia?

0 likes
2 replies
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

What helper do you need? Show the image code that is causing problems

My guess is that you just miss a leading /

1 like
tisuchi's avatar

@randy_johnson I think you can use mix(). In your React component, you can import the mix() helper and use it to generate the URL for the image.

For example:

import mix from 'laravel-mix';

function ProductImage(props) {
    return <img src={mix('/images/' + props.image)} alt={props.image} />;
}
1 like

Please or to participate in this conversation.