In React 18 SSRProvider is not necessary and is a noop. You can remove it from your app, how to resolve this warning?

huangapple go评论89阅读模式
英文:

In React 18 SSRProvider is not necessary and is a noop. You can remove it from your app, how to resolve this warning?

问题

Hello,我在React Native中遇到了这个错误。

在React 18中,SSRProvider是不必要的,它是一个空操作。您可以从应用程序中将其删除。

我尝试了使用@react-aria/ssr并使用<SSRProvider store={store}>而不是<Provider store={store}>,但没有解决这个警告。任何建议都将很有帮助。

我正在使用React 18.2.0,native base ^3.4.28,React Native 0.71.8。

以下是我的App.js中的代码:

<Provider store={store}>
    <NativeBaseProvider theme={theme}>
      <SafeAreaView style={{ flex: 1, backgroundColor: '#292929' }}>
        <StatusBar
          translucent
          backgroundColor="#292929"
          barStyle="light-content"
        />
        <AppNavigation />
      </SafeAreaView>
    </NativeBaseProvider>
  </Provider>

我尝试了使用@react-aria/ssr并使用<SSRProvider store={store}>而不是<Provider store={store}>,但没有解决这个警告。任何建议都将很有帮助。

英文:

Hello people im getting this error in react native
In React 18, SSRProvider is not necessary and is a noop. You can remove it from your app
I have tried this @react-aria/ssr and used <SSRProvider store={store}> instead of <Provider store={store}>, but not resolved the warning. any suggestions would be helpful.

Im using react 18.2.0, native base ^3.4.28, react native 0.71.8.

below is my code in App.js

&lt;Provider store={store}&gt;
    &lt;NativeBaseProvider theme={theme}&gt;
      &lt;SafeAreaView style={{flex: 1, backgroundColor: &#39;#292929&#39;}}&gt;
        &lt;StatusBar
          translucent
          backgroundColor=&quot;#292929&quot;
          barStyle=&quot;light-content&quot;
        /&gt;
        &lt;AppNavigation /&gt;
      &lt;/SafeAreaView&gt;
    &lt;/NativeBaseProvider&gt;
  &lt;/Provider&gt;

I have tried this @react-aria/ssr and used <SSRProvider store={store}> instead of <Provider store={store}>, but not resolved the warning. any suggestions would be helpful.

答案1

得分: 11

  1. 转到 node_modules/native-base/src/core/NativeBaseProvider.tsx
  2. 删除包裹 {children} 的 <SSRProvider></SSRProvider>。请注意不要删除 {children}。
  3. 移除 SSRProvider 导入。也就是删除这行代码 import { SSRProvider } from '@react-native-aria/utils';
  4. 运行 npx patch-package native-base。在提示中选择是。

当 Native Base 正式修复此问题时,您可以从创建的补丁目录中删除补丁并重新安装 native-base。

> 链接:https://github.com/GeekyAnts/NativeBase/issues/5758

英文:
  1. Navigate to node_modules/native-base/src/core/NativeBaseProvider.tsx
  2. Delete <SSRProvider></SSRProvider> that wraps {children}. Take care not to delete {children}.
  3. Remove SSRProvider import. That is, delete this line import { SSRProvider } from '@react-native-aria/utils';
  4. Run npx patch-package native-base. Select yes in the prompt.

When Native Base officially fixes it, you can delete the patch from the patch directory that was created and reinstall native-base

> https://github.com/GeekyAnts/NativeBase/issues/5758

答案2

得分: -1

为我添加了这个:

useEffect(() => {
    LogBox.ignoreLogs(['在 React 18 中,SSRProvider 不再必要,是一个无操作项。您可以从您的应用程序中删除它。']);
}, []);

不要忘记导入 LogBox

import { LogBox } from 'react-native';
英文:

for me I added this:

 useEffect(() =&gt; {
    LogBox.ignoreLogs([&#39;In React 18, SSRProvider is not necessary and is a noop. You can remove it from your app.&#39;]);
  }, []);

Don't forget to import {LogBox} from 'react-native';

huangapple
  • 本文由 发表于 2023年6月29日 16:36:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/76579391.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定