2017-06-19 4 views
1

追加してみましたか?スキーマエラーが認識されない

の 'name':{ タイプ:文字列、 オプション:真、 制服:TextFieldの }

simpleschemaでvazco/uniformsを実装しようとしているときに、私はエラーを取得しています。エラーメッセージは、Invariant Violation: Unrecognised schema: [object Object]です。このパッケージが何を求めているのかよく分かりません。

パス:Schema

import { Mongo } from 'meteor/mongo'; 
import SimpleSchema from 'simpl-schema'; 
import TextField from 'uniforms-bootstrap3/AutoForm'; // Choose your theme package. 

export const ProfileCandidate = new Mongo.Collection('profileCandidate'); 

const ProfileCandidateSchema = new SimpleSchema({ 
    'name.first': { 
    type: String, 
    optional: true, 
    uniforms: TextField 
    } 
}); 

ProfileCandidate.attachSchema(ProfileCandidateSchema); 

パス:Form

import AutoForm from 'uniforms-bootstrap3/AutoForm'; 
import ProfileCandidateSchema from '../../../../api/profileCandidate/profileCandidate'; 

export default class CareerHistoryFormPage extends Component { 
    constructor() { 
    super(...arguments); 

    this.handleSubmit = this.handleSubmit.bind(this); 
    } 

    handleSubmit(doc) { 
    console.log("Doc: ", doc); 
    } 

    render() { 
    return (
     <div className="paper"> 
     <AutoForm schema={ProfileCandidateSchema} onSubmit={this.handleSubmit} /> 
     </div> 
    ); 
    } 
} 

答えて

0
私は、この同じ問題に出くわしました ProfileCanidateスキーマは元のシンプルなスキーマに schemaの小道具を必要とすることを実現し

、それはすることができます別にProfileCanidateSchemaという名前が付けられています(私が通常使用する構文です)。これはあなたのためInvariant Violation: Unrecognised schema: [object Object]エラーを取り払う必要がある

import { Mongo } from 'meteor/mongo'; 
import SimpleSchema from 'simpl-schema'; 
import TextField from 'uniforms-bootstrap3/AutoForm'; // Choose your theme 
package. 

export const ProfileCandidate = new Mongo.Collection('profileCandidate'); 

ProfileCandidate.schema = new SimpleSchema({ 
    'name.first': { 
    type: String, 
    optional: true, 
    uniforms: TextField 
    } 
}); 

ProfileCandidate.attachSchema(ProfileCandidate.schema); 

import AutoForm from 'uniforms-bootstrap3/AutoForm'; 
import ProfileCandidate from 
'../../../../api/profileCandidate/profileCandidate'; 

export default class CareerHistoryFormPage extends Component { 
    constructor() { 
    super(...arguments); 

    this.handleSubmit = this.handleSubmit.bind(this); 
    } 

    handleSubmit(doc) { 
    console.log("Doc: ", doc); 
    } 

    render() { 
    return (
     <div className="paper"> 
     <AutoForm schema={ProfileCandidate.schema} onSubmit={this.handleSubmit} /> 
     </div> 
    ); 
    } 
} 

:だからあなたのコードを編集するために、物事はこの線に沿ってより多くのを見なければなりません。

関連する問題