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

Basic example in the docs not working #3295

Closed
4 tasks done
pathum-kalhan opened this issue Dec 15, 2022 · 2 comments
Closed
4 tasks done

Basic example in the docs not working #3295

pathum-kalhan opened this issue Dec 15, 2022 · 2 comments
Labels
bug needs triage Initial label given, to be assigned correct labels and assigned

Comments

@pathum-kalhan
Copy link

pathum-kalhan commented Dec 15, 2022

Prerequisites

What theme are you using?

core

Version

5.0.0-beta.14

Current Behavior

This is my code

import React from "react";
import validator from "@rjsf/validator-ajv8";
import Form from "@rjsf/core";

export default function Test() {
  const schema = {
    title: "Todo",
    type: "object",
    required: ["title"],
    properties: {
      title: { type: "string", title: "Title", default: "A new task" },
      done: { type: "boolean", title: "Done?", default: false }
    }
  };
// @ts-ignore
  const log = (type) => console.log.bind(console, type);

  return (
    <Form
    // @ts-ignore
      schema={schema}
      validator={validator}
      onChange={log("changed")}
      onSubmit={log("submitted")}
      onError={log("errors")}
    />
  );
}

When I tried to run this I am getting this error

[./node_modules/@rjsf/validator-ajv8/dist/validator-ajv8.esm.js 441:44
Module parse failed: Unexpected token (441:44)
File was processed with these loaders:
 * ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| 
|   isValid(schema, formData, rootSchema) {
>     const rootSchemaId = rootSchema["$id"] ?? ROOT_SCHEMA_PREFIX;
| 
|     try {](url)

These are the versions I am using

 "@rjsf/core": "^5.0.0-beta.14",
    "@rjsf/utils": "^5.0.0-beta.14",

Also, I tried the same thing in the code sandbox https://codesandbox.io/s/wizardly-wilson-nunesg?file=/src/App.js:0-625
There I am getting this error
Could not find module in path: 'ajv8' relative to '/node_modules/@rjsf/validator-ajv8/dist/validator-ajv8.esm.js'

Expected Behavior

No response

Steps To Reproduce

No response

Environment

- OS:Ubuntu 22.04.1 LTS
- Node:v19.2.0
- npm:8.19.3

Anything else?

No response

@pathum-kalhan pathum-kalhan added bug needs triage Initial label given, to be assigned correct labels and assigned labels Dec 15, 2022
@heath-freenome
Copy link
Member

This is a duplicate of #3240, closing

@nickgros
Copy link
Contributor

The error Could not find module in path: 'ajv8' relative to '/node_modules/@rjsf/validator-ajv8/dist/validator-ajv8.esm.js' is caused by a workaround that we used to fix our own module resolution issues in the playground. It's unclear if this is a CodeSandbox issue or if the issue can be encountered in other environments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs triage Initial label given, to be assigned correct labels and assigned
Projects
None yet
Development

No branches or pull requests

3 participants