Skip to content

Commit

Permalink
Merge pull request #18 from pepijnolivier/main
Browse files Browse the repository at this point in the history
Allow plugins to be registered before Vue is mounted
  • Loading branch information
ijpatricio authored Jul 20, 2024
2 parents 71310db + 4acfd37 commit bf1daf4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
12 changes: 10 additions & 2 deletions resources/js/mingleReact.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import {createRoot} from 'react-dom/client'

const createComponent = (mingleId, wireId, Component) => {
const createComponent = (mingleId, wireId, Component, options = {}) => {

const
el = document.getElementById(mingleId),
Expand All @@ -15,7 +15,15 @@ const createComponent = (mingleId, wireId, Component) => {

const root = createRoot(el)

root.render(<Component wire={wire} wireId={wireId} mingleData={JSON.parse(el.dataset.mingleData)} />)
let mingleData = JSON.parse(el.dataset.mingleData);

root.render(<Component wire={wire} wireId={wireId} mingleData={mingleData} />)

return {
root,
node: el,
mingleData
}
}

const registerReactMingle = (name, component) => {
Expand Down
12 changes: 9 additions & 3 deletions resources/js/mingleVue.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {createApp} from 'vue/dist/vue.esm-bundler'

const createComponent = (mingleId, wireId, component) => {
const createComponent = (mingleId, wireId, component, options = { autoMount: true }) => {

const
el = document.getElementById(mingleId),
Expand Down Expand Up @@ -34,9 +34,15 @@ const createComponent = (mingleId, wireId, component) => {

const app = createApp(component, props)

app.mount(el)
if (options.autoMount) {
app.mount(el)
}

return app;
return {
app,
node: el,
mingleData,
}
}

const registerVueMingle = (name, component) => {
Expand Down

0 comments on commit bf1daf4

Please sign in to comment.