我正在听关于udemy的反应课。现在我到达了代码的这一点
import java.util.regex.Pattern;
class Example {
public static void main (String[] args) throws java.lang.Exception {
check("aaaa", true);
check("a", true);
check("", true);
check("m", true);
check("n", true);
check("mn", false);
check("q", false);
check("nnnn", false);
}
private static void check(String text, boolean expect) {
boolean result = Pattern.matches("a*|[mn]", text);
System.out.println(
(result ? "Match " : "No match") +
(result == expect ? " OK " : " ERROR ") +
": " + text
);
}
}
在编译后遇到此错误消息,我不知道该怎么做或意味着什么
import React, { useState } from 'react';
import Person from './Person/Person';
import './App.css';
const app = props => {
const [personState, setPersonState] = useState({
persons: [
{name: "Fil", age: 30}
],
other: "other"
});
const switchHandler = () => {
setPersonState({
persons: [
{name: "Fil", age: 40}
]
})
};
return (
<div className="App">
<h1>I'm a react developer</h1>
<Person name={personState.persons[0].name} age={personState.persons[0].age}>I am a children</Person>
<button onClick={switchHandler}>Switch Name</button>
</div>
);
}
export default app;
答案 0 :(得分:2)
您的app
必须是PascalCase App
。是要使其成为一个组件。
将const app =
重命名为const App =