Skip to content

Dynamic shared runtime exposed with Store lost shared dataΒ #4271

Open
@ytytsophia

Description

@ytytsophia

App1 and App2 are in different git repository
App1 expose app1/getProjectId like :

class Store<T> {
  _value: T;

  set value(value: T) {
    this._value = value;
  }

  get value() {
    return this._value;
  }
}
const projectIdStore = new Store<string | undefined>();

const getProjectId = () => projectIdStore.value;

export const setProjectId = (value: string | undefined) =>
  (projectIdStore.value = value);
export default getProjectId;

I call setProjectId('1') in App1, and make app1/getProjectId shared in init functions like

shared: {
        react: {
          version: '17.0.2',
          scope: 'default',
          lib: () => React,
          shareConfig: {
            singleton: true,
            requiredVersion: '^17.0.2',
          },
        },
        'react-dom': {
          version: '17.0.2',
          scope: 'default',
          lib: () => ReactDOM,
          shareConfig: {
            singleton: true,
            requiredVersion: '^17.0.2',
          },
        },
        'project/getProjectId': {
          shareConfig: {
            singleton: true,
            requiredVersion: '^1.0.0',
          },
        },
      },

which I expect is in App2 , when I call app1/getProjectId, I can get the value which I set in App1 before, but I got undefined
What should I suppose to do ? Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions