You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I cloned the "hello-world-tab-without-sso" project from the "dev" branch. I have upgraded the app to V2 SDK.
I am using the useTeams function from the "msteams-react-base-component" package and it is returning the old context object structure instead of new context structure that is updated in teams sdk V2. I am using @microsoft/teams-js: "^2.0.0" in my app.
When I use the below pattern, it returns old structure from V1 sdk as well as in some cases the context object is returned null.
Example:
`
import { useTeams } from "msteams-react-base-component";
export default function App() {
const { context } = useTeams({})[0];
useEffect(() => {
// Returns old context model
console.log(context);
}, [context])
return (
<>Demo app</>
);
}
`
But when I use the app.getContext(), it returns the new structure as well as work perfectly every time.
`
import { app } from "@microsoft/teams-js";
import { ReactElement, useEffect, useState } from "react";
export default function App(): ReactElement {
const [context, setContext] = useState({} as app.Context);
I cloned the "hello-world-tab-without-sso" project from the "dev" branch. I have upgraded the app to V2 SDK.
I am using the useTeams function from the "msteams-react-base-component" package and it is returning the old context object structure instead of new context structure that is updated in teams sdk V2. I am using @microsoft/teams-js: "^2.0.0" in my app.
When I use the below pattern, it returns old structure from V1 sdk as well as in some cases the context object is returned null.
Example:
`
import { useTeams } from "msteams-react-base-component";
export default function App() {
const { context } = useTeams({})[0];
useEffect(() => {
// Returns old context model
console.log(context);
}, [context])
return (
<>Demo app</>
);
}
`
But when I use the app.getContext(), it returns the new structure as well as work perfectly every time.
`
import { app } from "@microsoft/teams-js";
import { ReactElement, useEffect, useState } from "react";
export default function App(): ReactElement {
const [context, setContext] = useState({} as app.Context);
useEffect(() => {
if (!app.isInitialized()) {
app.initialize();
}
app.getContext().then((context) => {
setContext(context);
console.log(context);
}).catch((err) => {
console.error("Error getting context -> ", err);
});
}, []);
return (
<>Demo app</>
);
}
`
I do not see any update this package "msteams-react-base-component".
The text was updated successfully, but these errors were encountered: