{"id":4976,"date":"2020-07-02T12:47:39","date_gmt":"2020-07-02T19:47:39","guid":{"rendered":"https:\/\/officedevblogs.wpengine.com\/?p=4976"},"modified":"2021-10-18T10:54:42","modified_gmt":"2021-10-18T17:54:42","slug":"a-lap-around-microsoft-graph-toolkit-day-13-using-microsoft-graph-toolkit-with-react","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/a-lap-around-microsoft-graph-toolkit-day-13-using-microsoft-graph-toolkit-with-react\/","title":{"rendered":"A Lap around Microsoft Graph Toolkit Day 13 \u2013 Using Microsoft Graph Toolkit with React"},"content":{"rendered":"<p><strong>Updates (December 2020):<\/strong><\/p>\n<p>As of December 11th, 2020, the Microsoft Graph Toolkit team released version 2.0. In this version, <a href=\"https:\/\/docs.microsoft.com\/en-us\/graph\/toolkit\/get-started\/mgt-react\"><strong>mgt-react<\/strong><\/a> is officially included as part of the project. There is a newly updated guide on<a href=\"https:\/\/docs.microsoft.com\/en-us\/graph\/toolkit\/get-started\/use-toolkit-with-react\"> how to use the Microsoft Graph Toolkit with React here.<\/a><\/p>\n<p><strong>Author: <span class=\"TextRun BCX0 SCXW191236700\" lang=\"IT-IT\" xml:lang=\"IT-IT\" data-contrast=\"auto\"><span class=\"NormalTextRun BCX0 SCXW191236700\">Fabio Franzini<\/span><\/span><\/strong>, Microsoft Office Development and Microsoft Business Application MVP<\/p>\n<p><a href=\"https:\/\/twitter.com\/franzinifabio\"><span data-contrast=\"none\">@franzinifabio<\/span><\/a><span data-contrast=\"auto\">|\u00a0<\/span><a href=\"https:\/\/github.com\/fabiofranzini\"><span data-contrast=\"none\">GitHub<\/span><\/a><span data-contrast=\"auto\">\u00a0|\u00a0<\/span><a href=\"https:\/\/www.linkedin.com\/in\/fabiofranzini\/\"><span data-contrast=\"none\">LinkedIn<\/span><\/a><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<h3><span data-contrast=\"none\">Introduction<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:40,&quot;335559739&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"auto\">Welcome to Day 13 of the <\/span><a href=\"https:\/\/aka.ms\/mgtlap\"><span data-contrast=\"none\">Microsoft Graph Toolkit blog series<\/span><\/a><span data-contrast=\"auto\">!<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">There are many application scenarios where developers need to create or modify stand-alone web applications using specific frameworks such as React\u00a0<\/span><span data-contrast=\"auto\">&#8211; not just<\/span><span data-contrast=\"auto\">\u00a0HTML\u00a0<\/span><span data-contrast=\"auto\">or<\/span><span data-contrast=\"auto\">\u00a0<\/span><span data-contrast=\"auto\">JavaScript.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><span data-contrast=\"auto\">Microsoft itself uses\u00a0<\/span><span data-contrast=\"auto\">this framework\u00a0<\/span><span data-contrast=\"auto\">in many services and libraries among the most famous there is Fluent UI, a UI control library used in the Microsoft 365 services ecosystem and beyond.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><span data-contrast=\"auto\">In this blog, we <\/span><span data-contrast=\"auto\">create a web application in React and\u00a0<\/span><span data-contrast=\"auto\">show you\u00a0<\/span><span data-contrast=\"auto\">how to\u00a0<\/span><span data-contrast=\"auto\">use the<\/span><span data-contrast=\"auto\">\u00a0<\/span><span data-contrast=\"auto\">Microsoft Graph Toolkit <\/span><span data-contrast=\"auto\">for<\/span><span data-contrast=\"auto\">\u00a0both<\/span><span data-contrast=\"auto\">\u00a0<\/span><span data-contrast=\"auto\">a<\/span><span data-contrast=\"auto\">uthentication\u00a0<\/span><span data-contrast=\"auto\">and e<\/span><span data-contrast=\"auto\">vent<\/span><span data-contrast=\"auto\">\u00a0visualization<\/span><span data-contrast=\"auto\">. \u00a0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><em><strong>Here is a preview of the web application<\/strong><\/em><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-large wp-image-4977\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/07\/React-App-1024x555.png\" alt=\"View of the React application that will be built\" width=\"1024\" height=\"555\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/07\/React-App-1024x555.png 1024w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/07\/React-App-300x163.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/07\/React-App-768x416.png 768w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/07\/React-App-1536x832.png 1536w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/07\/React-App.png 1920w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p><span data-contrast=\"auto\">In making the application, we use two approaches. <\/span><span data-contrast=\"auto\">First, we<\/span><span data-contrast=\"auto\">\u00a0integrate the MGT components directly with React<\/span><span data-contrast=\"auto\">\u00a0and<\/span><span data-contrast=\"auto\"> highlight<\/span><span data-contrast=\"auto\"> everything needed to make things work<\/span><span data-contrast=\"auto\">.\u00a0<\/span><span data-contrast=\"auto\">Then, we use the<\/span><span data-contrast=\"auto\">\u00a0MGT-React library<\/span><span data-contrast=\"auto\">,\u00a0<\/span><span data-contrast=\"auto\">a set of React controls that wrap<\/span><span data-contrast=\"auto\">\u00a0the MGT web component library.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<h3><span data-contrast=\"none\">Creating\u00a0Web\u00a0App in React<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:40,&quot;335559739&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"auto\">First<\/span><span data-contrast=\"auto\">,<\/span><span data-contrast=\"auto\">\u00a0w<\/span><span data-contrast=\"auto\">e <\/span><span data-contrast=\"auto\">create a<\/span><span data-contrast=\"auto\">\u00a0<\/span><span data-contrast=\"auto\">w<\/span><span data-contrast=\"auto\">eb\u00a0<\/span><span data-contrast=\"auto\">a<\/span><span data-contrast=\"auto\">pp in React.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">There are several ways to do this, but\u00a0<\/span><span data-contrast=\"auto\">let\u2019s make it easy by<\/span><span data-contrast=\"auto\">\u00a0us<\/span><span data-contrast=\"auto\">ing<\/span><span data-contrast=\"auto\">\u00a0a simple command called &#8220;create-react-app&#8221;.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><span data-contrast=\"auto\">This command is extremely powerful because, thanks to the many options available, it is possible to do the scaffolding of the entire project\u00a0<\/span><span data-contrast=\"auto\">with just a few<\/span><span data-contrast=\"auto\">\u00a0manual operations<\/span><span data-contrast=\"auto\">. \u00a0And,<\/span><span data-contrast=\"auto\">\u00a0by executing this command using \u201c<\/span><span data-contrast=\"auto\">npx<\/span><span data-contrast=\"auto\">\u201d<\/span><span data-contrast=\"auto\">,<\/span><span data-contrast=\"auto\"> we don&#8217;t need to worry about the version as it always runs the latest version available.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<pre class=\"lang: decode:true \">npx\u202fcreate-react-app\u202fdemo-mgt-react\u202f--template\u202ftypescript<\/pre>\n<p><span data-contrast=\"auto\">I added \u201c&#8211;template typescript\u201d as a parameter to use TypeScript as a programming language instead of the classic JavaScript.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">Now that we have created the project, we add the necessary\u00a0npm\u00a0librar<\/span><span data-contrast=\"auto\">y that is &#8220;@microsoft\/mgt&#8221;:<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<pre class=\"lang: decode:true \">npm\u202finstall\u202f@microsoft\/mgt\u202f\u2013save<\/pre>\n<p><strong>Using MGT Providers\u00a0<\/strong><\/p>\n<p><span data-contrast=\"auto\">To<\/span><span data-contrast=\"auto\"> recover data, this application requires you to have a provider configured. <\/span><span data-contrast=\"auto\">In this example we\u2019re using<\/span><span data-contrast=\"auto\">\u00a0<\/span><span data-contrast=\"auto\">MsalProvider<\/span><span data-contrast=\"auto\">, but we could use any other provider provided by MGT, it depends on the context in which you\u00a0<\/span><span data-contrast=\"auto\">have to<\/span><span data-contrast=\"auto\">\u00a0use it.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><span data-contrast=\"auto\">Inside the\u00a0<\/span><span data-contrast=\"auto\">App.tsx<\/span><span data-contrast=\"auto\">\u00a0file we are going to add the following code which<\/span><span data-contrast=\"auto\">\u00a0(when<\/span><span data-contrast=\"auto\">\u00a0using a valid Client-I<\/span><span data-contrast=\"auto\">D)<\/span><span data-contrast=\"auto\">\u00a0allows you to set\u00a0<\/span><span data-contrast=\"auto\">MsalProvider<\/span><span data-contrast=\"auto\">\u00a0and use its status to check if the user is logged in or not.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<pre class=\"lang: decode:true \">function\u202fApp()\u202f{ \n\u202f\u202fconst\u202f[isLoggedIn,\u202fsetIsLoggedIn]\u202f=\u202fuseState(false); \n\u202f\u202fProviders.globalProvider\u202f=\u202fnew\u202fMsalProvider({\u202fclientId:\u202f'[CLIENT_ID]'\u202f}); \n\u202f\u202fProviders.globalProvider.onStateChanged((e)\u202f=&gt;\u202f{ \n\u202f\u202f\u202f\u202fif\u202f(Providers.globalProvider.state\u202f!==\u202fProviderState.Loading) \n\u202f\u202f\u202f\u202f\u202f\u202fsetIsLoggedIn(Providers.globalProvider.state\u202f===\u202fProviderState.SignedIn); \n\u202f\u202f}); \n\u202f\u202f... \n}<\/pre>\n<p><strong>Using MGT\u00a0with &#8220;mgt-react&#8221;<\/strong><\/p>\n<p><span data-contrast=\"auto\">A<\/span><span data-contrast=\"auto\">\u00a0<\/span><span data-contrast=\"auto\">more<\/span><span data-contrast=\"auto\">\u00a0elegant way of integrating MGT with React is to use the mgt-react library. This is a library of React components that wraps all MGT components. Let&#8217;s see how it is used.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">First<\/span><span data-contrast=\"auto\">,<\/span><span data-contrast=\"auto\">\u00a0we need to add the\u00a0<\/span><span data-contrast=\"auto\">npm<\/span><span data-contrast=\"auto\">\u00a0package:<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<pre class=\"lang: decode:true \">npm\u202finstall\u202fmgt-react\u202f-\u2013save<\/pre>\n<p><span class=\"LineBreakBlob BlobObject DragDrop SCXW68329857 BCX0\"><span class=\"SCXW68329857 BCX0\">\u00a0<\/span><\/span><span class=\"TextRun SCXW68329857 BCX0\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW68329857 BCX0\">Then we import the components (React) that we want to use:<\/span><\/span><span class=\"EOP SCXW68329857 BCX0\" data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<pre class=\"lang: decode:true \">import\u202f{\u202fAgenda,\u202fMgtTemplateProps\u202f}\u202ffrom\u202f'mgt-react';<\/pre>\n<p><span data-contrast=\"auto\">All the attributes and events of the MGT component are mapped as properties of the corresponding React component, very simple.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">For the templating part, however, everything changes. We can use all the power and knowledge\u00a0<\/span><span data-contrast=\"auto\">i<\/span><span data-contrast=\"auto\">n React to define the template with the syntax and components in React!<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">We can define a React component that has the\u00a0MgtTemplateProps\u00a0object as its type of props, like this:<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<pre class=\"lang: decode:true \">import\u202f{\u202fMgtTemplateProps\u202f}\u202ffrom\u202f'mgt-react'; \n\nconst\u202fMyEvent\u202f=\u202f(props:\u202fMgtTemplateProps)\u202f=&gt;\u202f{ \n\u202f\u202fconst\u202f{\u202fevent\u202f}\u202f=\u202fprops.dataContext; \n\u202f\u202freturn\u202f&lt;div&gt;{event.subject}&lt;\/div&gt;; \n};<\/pre>\n<p><span class=\"TextRun SCXW263194126 BCX0\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW263194126 BCX0\">And use it in the component (always React) Agenda like this:<\/span><\/span><span class=\"EOP SCXW263194126 BCX0\" data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<pre class=\"lang: decode:true \">import\u202f{\u202fAgenda\u202f}\u202ffrom\u202f'mgt-react'; \n \nconst\u202fApp\u202f=\u202f(props)\u202f=&gt;\u202f{ \n\u202f\u202freturn\u202f&lt;Agenda&gt; \n\u202f\u202f\u202f\u202f&lt;MyEvent\u202ftemplate=\"event\"&gt; \n\u202f\u202f&lt;\/Agenda&gt; \n}<\/pre>\n<p><span data-contrast=\"auto\">The &#8220;template&#8221; property<\/span><span data-contrast=\"auto\">\u00a0(<\/span><span data-contrast=\"auto\">defined into the \u201d<\/span><span data-contrast=\"auto\">MgtTemplateProps<\/span><span data-contrast=\"auto\">\u201d type<\/span><span data-contrast=\"auto\">)<\/span><span data-contrast=\"auto\">\u00a0is used to understand which template (available in the Agenda control)\u00a0<\/span><span data-contrast=\"auto\">is associated with\u00a0<\/span><span data-contrast=\"auto\">the\u00a0<\/span><span data-contrast=\"auto\">MyEvent<\/span><span data-contrast=\"auto\">\u00a0control<\/span><span data-contrast=\"auto\">.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">In this case, there is no need to use the ref property to &#8220;hook&#8221; the context of the template with custom functions. <\/span><span data-contrast=\"auto\">S<\/span><span data-contrast=\"auto\">imply create the functions you need in the component that acts as a template.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">Let&#8217;s now implement the same template as before with the new set of React controls:<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<pre class=\"lang: decode:true \">import\u202fReact\u202ffrom\u202f'react'; \nimport\u202f'@microsoft\/mgt'; \nimport\u202f{\u202fAgenda,\u202fMgtTemplateProps\u202f}\u202ffrom\u202f'mgt-react'; \n \nconst\u202fAgendaReact =\u202f()\u202f=&gt;\u202f{ \n\u202f\u202f\u202f\u202freturn\u202f( \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f&lt;Agenda\u202fgroupByDay={true}\u202f&gt; \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f&lt;Event\u202ftemplate=\"event\"\u202f\/&gt; \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f&lt;NoData\u202ftemplate=\"no-data\"\u202f\/&gt; \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f&lt;\/Agenda&gt; \n\u202f\u202f\u202f\u202f); \n} \n \nconst\u202fEvent\u202f=\u202f(props:\u202fMgtTemplateProps)\u202f=&gt;\u202f{ \n\u202f\u202f\u202f\u202fconst\u202f{\u202fevent\u202f}\u202f=\u202fprops.dataContext; \n\u202f\u202f\u202f\u202fconst\u202fopenWebLink\u202f=\u202f()\u202f=&gt;\u202f{ \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202fwindow.open(event.webLink,\u202f'_blank'); \n\u202f\u202f\u202f\u202f}; \n \n\u202f\u202f\u202f\u202fconst\u202fgetDate\u202f=\u202f(dateString:\u202fstring)\u202f=&gt;\u202f{ \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202flet\u202fdateObject\u202f=\u202fnew\u202fDate(dateString); \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202freturn\u202fdateObject.setHours(0,\u202f0,\u202f0,\u202f0); \n\u202f\u202f\u202f\u202f}; \n \n\u202f\u202f\u202f\u202fconst\u202fgetTime\u202f=\u202f(dateString:\u202fstring)\u202f=&gt;\u202f{ \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202flet\u202fdateObject\u202f=\u202fnew\u202fDate(dateString); \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202freturn\u202fdateObject.getHours().toString().padStart(2,\u202f'0') \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f+\u202f':'\u202f+ \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202fdateObject.getMinutes().toString().padStart(2,\u202f'0'); \n\u202f\u202f\u202f\u202f}; \n \n\u202f\u202f\u202f\u202freturn\u202f( \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f&lt;div\u202fclassName=\"...\"&gt; \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f&lt;div\u202fclassName=\"...\"\u202fonClick={()\u202f=&gt;\u202f{\u202fopenWebLink();\u202f}}&gt; \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f{event.subject} \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f&lt;\/div&gt; \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f{(getDate(event.start.dateTime) \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f==\u202fgetDate(event.end.dateTime))\u202f? \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f&lt;div\u202fclassName=\"...\"&gt; \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202ffrom\u202f{getTime(event.start.dateTime)} \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202fto\u202f{getTime(event.end.dateTime)} \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f&lt;\/div&gt; \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f:\u202fnull \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f} \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f{(event.body.content\u202f!=\u202f'')\u202f? \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f&lt;div\u202fclassName=\"...\" \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202fdangerouslySetInnerHTML={{\u202f__html:\u202fevent.body.content\u202f}}\u202f\/&gt; \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f:\u202fnull \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f} \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202f&lt;\/div&gt; \n\u202f\u202f\u202f\u202f); \n}; \n \nconst\u202fNoData\u202f=\u202f(props:\u202fMgtTemplateProps)\u202f=&gt;\u202f{ \n\u202f\u202f\u202f\u202freturn\u202f&lt;div\u202fclassName=\"...\"&gt; \n\u202f\u202f\u202f\u202f\u202f\u202f\u202f\u202fNo\u202fevents\u202fto\u202fshow \n\u202f\u202f\u202f\u202f\u202f\u202f&lt;\/div&gt; \n}; \n \nexport\u202fdefault\u202fAgendaReact;<\/pre>\n<p><strong>Add a style to this React App\u00a0<\/strong><\/p>\n<p><span data-contrast=\"auto\">Obviously<\/span><span data-contrast=\"auto\">,<\/span><span data-contrast=\"auto\">\u00a0what is missing is a bit of style. MGT components already have their own style, but when we go to define our\u00a0<\/span><span data-contrast=\"auto\">templates,<\/span><span data-contrast=\"auto\">\u00a0we\u00a0<\/span><span data-contrast=\"auto\">must<\/span><span data-contrast=\"auto\">\u00a0make do with the CSS we want to use. In this example application I used a very interesting CSS framework, Tailwind CSS<\/span><span data-contrast=\"auto\">, added as a regular\u00a0<\/span><span data-contrast=\"auto\">npm<\/span><span data-contrast=\"auto\">\u00a0package:<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<pre class=\"lang: decode:true \">npm\u202finstall\u202ftailwindcss\u202f-\u2013save<\/pre>\n<p><span class=\"TextRun SCXW194191341 BCX0\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW194191341 BCX0\">As for\u00a0<\/span><\/span><span class=\"TextRun SCXW194191341 BCX0\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW194191341 BCX0\">T<\/span><\/span><span class=\"TextRun SCXW194191341 BCX0\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW194191341 BCX0\">ailwind<\/span><\/span><span class=\"TextRun SCXW194191341 BCX0\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW194191341 BCX0\">\u00a0<\/span><\/span><span class=\"TextRun SCXW194191341 BCX0\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW194191341 BCX0\">CSS<\/span><\/span><span class=\"TextRun SCXW194191341 BCX0\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW194191341 BCX0\">, the only thing we need to do before using it in the project is to create a file like &#8220;tailwind.<\/span><span class=\"NormalTextRun SpellingErrorV2 DefaultHighlightTransition SCXW194191341 BCX0\">css<\/span><span class=\"NormalTextRun SCXW194191341 BCX0\">&#8221; in the root of the \u201c<\/span><\/span><span class=\"TextRun SCXW194191341 BCX0\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SpellingErrorV2 SCXW194191341 BCX0\">src<\/span><\/span><span class=\"TextRun SCXW194191341 BCX0\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW194191341 BCX0\">\u201d folder and\u00a0<\/span><\/span><span class=\"TextRun SCXW194191341 BCX0\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW194191341 BCX0\">add this<\/span><\/span><span class=\"TextRun SCXW194191341 BCX0\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW194191341 BCX0\">\u00a0content:<\/span><\/span><span class=\"EOP SCXW194191341 BCX0\" data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<pre class=\"lang: decode:true \">@tailwind\u202fbase; \n@tailwind\u202fcomponents; \n@tailwind\u202futilities;<\/pre>\n<p><span data-contrast=\"auto\">This is used by the\u00a0<\/span><span data-contrast=\"auto\">T<\/span><span data-contrast=\"auto\">ailwind<\/span><span data-contrast=\"auto\">\u00a0CSS<\/span><span data-contrast=\"auto\">\u00a0<\/span><span data-contrast=\"auto\">compiler to\u00a0<\/span><span data-contrast=\"auto\">generate the CSS that will contain the classes used.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">Now the only thing to do is to use the classes that the framework makes available to give style to the application.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><span data-contrast=\"auto\">I leave you at the official link to learn more about\u00a0<\/span><span data-contrast=\"auto\">T<\/span><span data-contrast=\"auto\">ailwind<\/span><span data-contrast=\"auto\">\u00a0CSS<\/span><span data-contrast=\"auto\">\u00a0<\/span><span data-contrast=\"auto\">here:\u00a0<\/span><a href=\"https:\/\/tailwindcss.com\/\"><span data-contrast=\"none\">https:\/\/tailwindcss.com\/<\/span><\/a><span data-contrast=\"none\">.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<h3><span data-contrast=\"none\">Recap<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:40,&quot;335559739&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"auto\">We have come to an end and we have managed to use MGT within a React application.<\/span><\/p>\n<p><span data-contrast=\"none\">You can find the\u202fsource code for this\u202fReact App sample here:\u00a0<\/span><a href=\"https:\/\/github.com\/microsoftgraph\/mgtLap-TryItOut\"><span data-contrast=\"none\">https:\/\/github.com\/microsoftgraph\/mgtLap-TryItOut<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome to Day 13 of the\u00a0Microsoft Graph Toolkit blog series!\u00a0There are many application scenarios where developers need to create or modify stand-alone web applications using specific frameworks such as React\u00a0&#8211; not just\u00a0HTML\u00a0or\u00a0JavaScript.\u00a0In this blog, we create a web application in React and\u00a0show you\u00a0how to\u00a0use the\u00a0Microsoft Graph Toolkit for\u00a0both\u00a0authentication\u00a0and event\u00a0visualization. \u00a0\u00a0<\/p>\n","protected":false},"author":69077,"featured_media":25159,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[3],"tags":[34],"class_list":["post-4976","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-microsoft-graph","tag-microsoft-graph-toolkit"],"acf":[],"blog_post_summary":"<p>Welcome to Day 13 of the\u00a0Microsoft Graph Toolkit blog series!\u00a0There are many application scenarios where developers need to create or modify stand-alone web applications using specific frameworks such as React\u00a0&#8211; not just\u00a0HTML\u00a0or\u00a0JavaScript.\u00a0In this blog, we create a web application in React and\u00a0show you\u00a0how to\u00a0use the\u00a0Microsoft Graph Toolkit for\u00a0both\u00a0authentication\u00a0and event\u00a0visualization. \u00a0\u00a0<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/4976","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/users\/69077"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/comments?post=4976"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/4976\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media\/25159"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media?parent=4976"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/categories?post=4976"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/tags?post=4976"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}