0
以下代碼給我一個Uncaught Invariant Violation
。我不知道爲什麼。它幾乎完全是從Bootstrap例子中複製的。使用React Bootstrap獲得不變違規
Uncaught Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. Check the render method of 'LoginForm'.
import React from 'react';
import { FormGroup, ControlLabel, FormControl, HelpBlock, Button } from 'bootstrap/dist/css/bootstrap.css';
const FieldGroup = ({ id, label, help, ...props }) => {
return (
<FormGroup controlId={id}>
<ControlLabel>{label}</ControlLabel>
<FormControl {...props} />
{help && <HelpBlock>{help}</HelpBlock>}
</FormGroup>
);
};
const LoginForm = props => {
return (
<form>
<FieldGroup
id="loginText"
type="text"
label="Text"
placeholder="Email"
/>
<FieldGroup
id="loginPassword"
label="Password"
type="password"
/>
<Button type="submit">
Login
</Button>
</form>
);
};
export const LoginCtrl = props => {
return (<LoginForm/>);
};
不是JavaScript導入拋出錯誤? –
取決於您的構建設置,特別是如果您使用css-loader或類似的WebPack,它不會拋出,因爲.css文件不是一個JavaScript模塊。這是別的,這是由一個特定的裝載機處理。 –