I'm facing an issue in react-admins ra-data-json-server.
import jsonServerProvider from 'ra-data-json-server';
const dataProvider = jsonServerProvider('https://jsonplaceholder.typicode.com');
export default function App() {
return (
<Admin dataProvider={dataProvider}>
<Resource
name="posts"
list={ListGuesser}
show={ShowGuesser}
edit={EditGuesser}
/>
</Admin>
);
}
getting the console error:
Error: Unknown dataProvider function: toJSON
at Proxy.eval (useDataProvider.ts:96:31)
at JSON.stringify (<anonymous>)
at Object.parseData (<anonymous>:8:116)
at <anonymous>:10:2186
at Array.reduce (<anonymous>)
at <anonymous>:10:2114
at i (<anonymous>:10:2706)
at <anonymous>:10:2993
at _ (<anonymous>:10:3119)
at <anonymous>:10:3363
The application is running, the data that is fetched looks correct, but i can not get rid of the console error of the react_devtools_backend.
I created a minimal react-admin app using the jsonplaceholder api on stackblitz.io. Even there the console error is showing up every time.
Url to the minimal app where you can see the console error if you have react-dev-tools installed: https://react-ts-rj6rfi.stackblitz.io/#/posts
Used packages:
react-admin: 4.5.2
ra-data-json-server: 4.5.2
react: 18.2.0
react-dom: 18.2.0
If you're using the JSONPlaceholder API, why don't you use ra-data-json-server instead of ra-data-simple-rest? The former is designed for that API language.
As for your error, the latest react-admin codebase doesn't have a single toSJON call. So the error must come from another package in your installation. And your error message doesn't help because the trace only shows <anonympus>...
Related
I have been trying to get Firebase Real Time Database to work. Though, I consistently get errors. I followed this guide and have successfully gotten other packages from here working. I have the 16.5.0 version. The rules of the Database is set to true.
I installed React Native with Expo.
Code inside of a function:
database()
.ref('/users/123')
.once('value')
.then((snapshot) => {
console.log('User data: ', snapshot.val());
});
Database:
{
"users": {
"123": ""
}
}
Calling of the function results in:
TypeError: this._database.native.once is not a function. (In 'this._database.native.once(this.path, modifiers, eventType)', 'this._database.native.once' is undefined)
While hovering over database() VS Intellisense says:
database(app?: ReactNativeFirebase.FirebaseApp | undefined): FirebaseDatabaseTypes.Module
import database
I have tried different methods for database() and ref(), according to the documentations, but nothing seems to be working.
Anyone know why I get this error, and how to fix it?
Running npx expo run:android and updating the Android Emulator solved the issue.
While implementing google login using the expo-auth-session package , I am getting some error that i don't have any idea about, It has been more than one day since i am stuck in this problem i cannot find a reliable source to use for implementing google login in my expo application. Is there any other way i can implement it in the react native expo application.
The error i am getting are :
WARN Linking requires a build-time setting `scheme` in the project's Expo config (app.config.js or app.json) for production apps, if it's left blank, your app may crash. The scheme does not apply to development in the Expo client but you should add it as soon as you start working with Linking to avoid creating a broken build. [Learn more][1]:
WARN EventEmitter.removeListener('url', ...): Method has been deprecated. Please instead use `remove()` on the subscription returned by `EventEmitter.addListener`.
WARN Possible Unhandled Promise Rejection (id: 2):
Error: Exception in HostFunction: Malformed calls from JS: field sizes are different.
What should i do ??
The link to the documentation that i followed is :-
And this is what i used from the documentation.
import * as Google from "expo-auth-session/providers/google";
import * as WebBrowser from "expo-web-browser";
WebBrowser.maybeCompleteAuthSession();
const [request, response, promptAsync] = Google.useAuthRequest({
expoClientId: expoClientId,
});
const login = ()=>{
useEffect(() => {
if (response?.type === "success") {
const { authentication } = response;
console.log(authentication);
}
}, [response]);
return (
<Pressable style={styles.btn} onPress={promptAsync}>
<Image
source={require("../../../assets/g1.png")}
style={styles.img}
/>
<Text style={styles.text}>Sign in with Google</Text>
</Pressable>
)
}
thank you any help would be appriciated.
In your app.json add following
"scheme":"com.yourpackage.yourapp"
this value must be same as your android.package and ios.bundleIdentifier
Code:
import {
GoogleSigninButton,GoogleSignin
} from '#react-native-google-signin/google-signin';
const CLIENT_ID = "client_id";
<GoogleSigninButton
clientId={CLIENT_ID}
render={(renderProps) => (
<Button
className={classes.googleButton}
color="secondary"
fullWidth
onClick={renderProps.onClick}
disabled={renderProps.disabled}
variant="contained"
>
Google Sign In
</Button>
)}
onSuccess={googleSuccess}
onFailure={googleError}
cookiePolicy="single_host_origin"
/>
Error message:
ERROR RN GoogleSignin native module is not correctly linked. Please read the readme, setup and troubleshooting instructions carefully or try manual linking. If you're using Expo, please use expo-google-sign-in. This is because Expo does not support custom native modules.
ERROR TypeError: null is not an object (evaluating 'RNGoogleSignin.SIGN_IN_CANCELLED')
ERROR Invariant Violation: "main" has not been registered. This can happen if:
Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
A module failed to load due to an error and AppRegistry.registerComponent wasn't called.
I have a component that uses #stripe/stripe-react-native named NativeCheckout.
This package does not work on web (Chrome), and when I import it I get an error:
Failed to compile
/home/joey/Projects/project/project_frontend/node_modules/#stripe/stripe-react-native/lib/module/components/StripeProvider.js
Module not found: Can't resolve '../../package.json' in '/home/joey/Projects/project/project_frontend/node_modules/#stripe/stripe-react-native/lib/module/components'
So if I run it in my browser, I do not want this component. This component is only rendered on native apps. I have found three alternative ways to import the Component. If my code is working fine then I add any of the follow lines, the above error is happening. I thought this would not load in the problem code.
const loadNative = async () => {
await import("./NativeCheckout")
}
const NativeCheckout = lazy(() => import("./NativeCheckout"));
const NativeCheckout = lazy(() => import("./NativeCheckout"));
Does anyone know a way to make this work?
TIA
I'm trying to test my app using jest but encountered an error "You attempted to use a firebase module that's not installed on your Android project by calling firebase.app()". Below is my code
import firebase from '#react-native-firebase/app';
test('renders correctly', () => {
Platform.OS = 'android';
firebase.initializeApp({//credentials hidden
});
const _firestore = firebase.firestore();
const personStore = new PersonStore(_firestore);
const app = renderer
.create(
<Provider {...personStore}>
<PersonInfo />
</Provider>,
)
.getInstance();
});
What am I missing?
I've tried this solution https://rnfirebase.io/install-android but to no avail
And #react-native-firebase/app is working if I'm not in test mode
Try the getting started steps: Getting Started
The solution you tried is a secondary step.
Also firebase is segmented in modules, so you should install the required modules separated. if you are going to use the firestore you have to install the module.
Firestore Module
for me the problem was with mismatch in the package name of the app throughout the project (I started out with a MyApp project and then changed the name but not in all the necessary places).
I then followed these steps to rename everything and it started working