Skip to content

Unable to find module #388

@smaili

Description

@smaili

Trying to use the following:

import React, {Component, PropTypes} from 'react';
import Form from "react-jsonschema-form";

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}
  }
};

class MyForm extends Component {
  static propTypes = {}

  constructor(props) {
    super(props);
  }

  onFormChange() {}

  onFormSubmit() {}

  onFormError() {}

  render() {
    return (
      <Form schema={schema}
         onChange={this.onFormChange}
         onSubmit={this.onFormSubmit}
         onError={this.onFormError} />
    );
  }
}

export default MyForm;

but getting this error: Uncaught Error: Cannot find module './components/fields/SchemaField'

Inspecting the code, it appears the load helper is unable to find the modules:

  var load = function load(prefix, arr) {
    return arr.reduce(function (obj, comp) {
      obj[comp] = require("./components/" + prefix + "/" + comp).default;
      return obj;
    }, {});
  };

Is this library only intended to work server-side?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions