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

Unable to find module #388

Closed
smaili opened this issue Nov 10, 2016 · 3 comments
Closed

Unable to find module #388

smaili opened this issue Nov 10, 2016 · 3 comments

Comments

@smaili
Copy link

smaili commented Nov 10, 2016

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?

@glasserc
Copy link
Contributor

Is this related to #385/#387?

@n1k0
Copy link
Collaborator

n1k0 commented Nov 11, 2016

Yeah, most probably. I'm closing this as the fix has landed.

@n1k0 n1k0 closed this as completed Nov 11, 2016
@smaili
Copy link
Author

smaili commented Nov 11, 2016

Yep you're right, sorry I missed those!

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

3 participants