Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

See if using DarkReader.setFetchMethod(window.fetch) before DarkReader.enable() works. #16

Open
wanglihuaya opened this issue Feb 8, 2022 · 0 comments

Comments

@wanglihuaya
Copy link

import Darkreader from 'react-darkreader';
import { useModel } from 'umi';


export default () => {
  const { setInitialState } = useModel('@@initialState');
  return (
    <>
      <Darkreader
        theme={{
          brightness: 100,
          contrast: 90,
          sepia: 10,
        }}
        onChange={(isDark: any) => { setInitialState((s) => ({ ...s, isDark })) }}
        defaultDarken={false}
      />
    </>
  );
};

控制台报

Error: Embedded Dark Reader cannot access a cross-origin resource https://gw.alipayobjects.com/zos/antfincdn/DehQfMbOJb/icon.svg Overview your URLs and CORS policies or use DarkReader.setFetchMethod(fetch: (url) => Promise<Response>)). See if using DarkReader.setFetchMethod(window.fetch) before DarkReader.enable() works.

"react": "^17.0.0",
"name": "react-darkreader",
"version": "1.5.6",

请问如何解决这个问题呢,谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant