大家好,我想使用React、Azure AD和typescript实现单点登录身份验证,问题是我的呈现文件中出现了此类型错误,不知道如何解决。以下是错误,感谢您的建议:
Type '{ msalInstance: PublicClientApplication; environment: Environment.Browser; }' is not assignable to type 'IntrinsicAttributes & Props'.
Property 'msalInstance' does not exist on type 'IntrinsicAttributes & Props'.
渲染.tsx:
import React from 'react';
import ReactDOM from 'react-dom/client';
import { App } from './App';
import * as serviceWorkerRegistration from './serviceWorkerRegistration';
import reportWebVitals from './reportWebVitals';
import { Environment } from '../types';
import { PublicClientApplication } from '@azure/msal-browser';
interface PcaProps {
msalInstance: string;
}
const pca = new PublicClientApplication({
auth: {
clientId: '...-...-...-...',
authority: 'https://login.microsoftonline.com/.......',
redirectUri: '/',
}
})
function render() {
const rootElement = document.getElementById('app-root');
if (!rootElement) throw new Error('Failed to find the root element');
const root = ReactDOM.createRoot(rootElement);
root.render(
<React.StrictMode>
<App msalInstance={pca} environment={Environment.Browser} />
</React.StrictMode>,
);
serviceWorkerRegistration.unregister();
reportWebVitals();
}
export { render };
应用程序tsx:
import React from 'react';
import { Providers } from './providers';
import { Routing } from './Routing';
import type { FC } from 'react';
import type { Environment } from '../types';
interface Props {
environment: Environment;
}
const App: FC<Props> = ({ environment }) => (
<Providers environment={environment}>
<Routing />
</Providers>
);
export { App };
1条答案
按热度按时间oxf4rvwz1#
难道你没有错过一个msalInstance:公共客户端应用程序;在你的 prop 里吗