reactjsmicrosoft-graph-toolkit

How to use MgtTeamsChannelPicker in React?


I imported all necessary libs.

import "@microsoft/mgt";
import "@microsoft/teams-js"

put tag MgtTeamsChannelPicker into my render section

render() {
  return (
    <MgtTeamsChannelPicker></MgtTeamsChannelPicker>    
  );
}

than i got an error. enter image description here


Solution

  • Due to how react handles custom elements, they must be referenced differently. Alternatively you can use our wrapper here:

    https://github.com/nmetulev/mgt-react

    which will allow you to reference the component in the following way:

    import { TeamsChannelPicker } from 'mgt-react';
    <TeamsChannelPicker></TeamsChannelPicker>
    

    quick note: The names of the React components are in PascalCase and do not include the Mgt prefix