kkazala / spfx-Panel

https://dev.to/kkazala/panel-for-listview-command-set-sharepoint-online-4hp8
7 stars 1 forks source link

Dynamic Form context is not accepting ListViewCommandSet context #5

Closed praveenhooda closed 1 year ago

praveenhooda commented 1 year ago
  1. ListViewCommandSet context should be assignable to BaseComponentContext of Dynamic Form control such as:

context: BaseComponentContext; is declared as property of MyComponent which is rendering DynamicForm as below <DynamicForm context={props.context} listId={"List ID"}

            listItemId={1}
            onCancelled={() => { console.log('Cancelled') }}
            onBeforeSubmit={async (listItem) => { return false; }}
            onSubmitError={(listItem, error) => { alert(error.message); }}
            onSubmitted={async (listItemData) => { console.log(listItemData); }}>
        </DynamicForm>
  1. MyComponent is created in ListViewCommandSet and this.context of ListViewCommandSet is assigned to context property of MyComponent

Please suggest

praveenhooda commented 1 year ago

And the Error I get is Type 'import("/node_modules/@microsoft/sp-component-base/dist/index-internal").BaseComponentContext' is not assignable to type 'import("/node_modules/@pnp/spfx-controls-react/node_modules/@microsoft/sp-component-base/dist/index-internal").BaseComponentContext'. Types have separate declarations of a private property '_serviceScope'.ts(2322) IDynamicFormProps.d.ts(9, 5): The expected type comes from property 'context' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly & Readonly<...>'

praveenhooda commented 1 year ago

Closing it since it was answered on another post!