Why can't I do this in react?
import React from 'react';
export default class App extends React.Component {
somefun() {
return (<p>hello</p>);
}
render() {
return (
{somefun()}
)
}
}
When I try I get a compile error
SyntaxError: C:\Users\karln\baeldung\my-app\src\App.js: Unexpected token, expected "{" (9:13)
7 | render() {
8 | return (
> 9 | {somefun()}
| ^
10 | )
11 | }
12 | }
I'm new to react and getting through, but this one kind of vexes me.
return (<div>{someFun()}</div>)(<div>{somefun()}</div>)but I thought that was messy. What is<>{somefun()}<>and what does it do? I assume that would not generate any html other than what is produced bysomefun?