I've a problem and somehow I just can't solve it. I tried everything for hours but I just don't find a solution. It worked in older projects, but doesn't work with a brand new react project created with create-react-app.
Consider the following code:
App.js:
function App() {
const test = {
test1: {},
test2: {}
};
return (
<div className="App">
Cool!
<Test
name1="cool1"
{...test}
/>
</div>
);
}
export default App;
Nothing big here. If I start the project with npm start, everything works as expected and I see the "Cool!" in the Browser. (Test is defined below, its a simple component that returns a div.)
Now, if I try to use ...props
in my function parameters for Test, like this:
export const Test = ({name1, ...props}) => {
return (
<div>yay! {props.name1}</div>
)
};
It works fine in chrome, but Microsoft edge says:
SCRIPT1028: SCRIPT1028: Expected identifier, string or number
I use this syntax in older projects, created with older version of create-react-app without any problem, so I'm not too sure where the problem is. Could this even be a general bug in the create-react-app, since the project is literally created with it and has no libraries added to it.
Best Regards and thanks for any help!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…