akxcv / vuera

:eyes: Vue in React, React in Vue. Seamless integration of the two. :dancers:
MIT License
4.3k stars 242 forks source link

Add config class #94

Closed phillbaker closed 4 years ago

phillbaker commented 5 years ago

Redo of https://github.com/akxcv/vuera/pull/90. ea55634 fixes the build bug in https://github.com/akxcv/vuera/pull/90#issuecomment-529439080 - sorry about that!

Also closes https://github.com/akxcv/vuera/pull/83

phillbaker commented 5 years ago

@akxcv any thoughts here? Happy to investigate the failing tests if this makes sense.

phillbaker commented 5 years ago

cc @fanyer since it seems like you're helping out on this repo now (based on #97 )

timsayshey commented 4 years ago

@phillbaker Is this pull-request dead?

phillbaker commented 4 years ago

Was waiting on a review/merge. But seems like it would still be useful and relevant.

On Sat, Jan 18, 2020 at 12:25 AM Tim Badolato notifications@github.com wrote:

@phillbaker https://github.com/phillbaker Is this pull-request dead?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/akxcv/vuera/pull/94?email_source=notifications&email_token=AAAXCKOTTIF5UPK6LRAD73DQ6KHFPA5CNFSM4IVGM2G2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJJQ4QA#issuecomment-575868480, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAXCKNY56IF6OOPGSS7FELQ6KHFPANCNFSM4IVGM2GQ .

akxcv commented 4 years ago

Hey, I thought I commented on this, but apparently not. I thought that making config a JS class would be more readable/maintainable, but an object will do for now. Could you please describe in a few words how to actually use this feature in code? Could you provide a minimal sample?

phillbaker commented 4 years ago

Thanks @akxcv for taking another look.

Could you please describe in a few words how to actually use this feature in code?

The key problem this is solving is that instance options set at the top level Vue instances are not passed down to Vue instances within react components. So, for example an i18n instance option configured at the top level is not available in the children Vue components wrapped in React components.

Could you provide a minimal sample?

Sure - very similar to the example, in https://github.com/akxcv/vuera/pull/83#issue-283419857:

import Vue from "vue";
import { config } from "vuera";
import VueI18n from "vue-i18n";
import React from "react";
import { render } from "react-dom";
import { VsTable } from "example-vue-component-library";

Vue.use(VueI18n);
const i18n = new VueI18n({
  locale: "en",
  messages: {
    en: {
      no_data: "No data"
    }
  }
});

config.vueInstanceOptions = { i18n };

render(
  <div>
    <VsTable data={[]} />
  </div>,
  document.querySelector("#app")
);
akxcv commented 4 years ago

Yeah, this will work for now. Could you please describe this functionality in the README? Then we can merge this.

phillbaker commented 4 years ago

Done!