score:4
Accepted answer
yes, that is correct. when you have only one expression, and it's the expression you wish to return from the function, you may omit the curly brackets.
since <div><label>{props.placeholder}</label></div>
is, in fact, a single expression (it gets transpiled to react.createelement(......)
or something like that), and you wish to return it from renderinput
, that is indeed how you use the no-brackets version of the arrow function.
if you had wished to use variables or do some other computation (conditions, for loops, etc), you wouldn't have been able to omit the brackets.
Source: stackoverflow.com
Related Query
- ES6 Arrow function without curly braces
- Arrow function without curly braces
- curly braces in es6 arrow function for each
- Using arrow function with curly braces and ternary operator for setState's callback error?
- Why does adding/removing curly braces in this arrow function cause the text to not display for a ReactJS component?
- What is use of curly braces in an ES6 import statement?
- setTimeout ReactJS with arrow function es6
- React.createClass vs. ES6 arrow function
- What do curly braces around a variable in a function parameter mean
- setInterval function without arrow function
- How to test arrow function in React ES6 class
- JS: What do the curly braces inside function parameter declarations mean?
- One line arrow functions without braces - can't have a semicolon?
- Is it possible to type a React function component with TypeScript without using arrow functions?
- What is the difference between using only paranthesis and curly braces within paranthesis while defining function in ReactJS?
- Why I'm able to use this.state without having to bind or use arrow function React
- Difference between this ES6 arrow function and regular function?
- es6 arrow function in class property
- Why do I need curly braces for nested JSX, even if it is working without it
- Pass event args and event object to event handler without arrow function in ReactJS
- Arrow function syntax with parentheses instead of curly braces?
- Curly braces inside array destructuring in return from a function
- Different output fetching json with and without arrow function on reactjs
- Es6 React Arrow function behaviour
- Curly braces as function parameter
- react javascript arrow function without arrows?
- How to make a use of arrow function in es6 instead of bind method
- Multiple function calls inside curly braces in React JSX
- Preferred ES6 arrow function syntax formatting
- passing argument to function in react without using arrow function in onClick handler
More Query from same tag
- React mapping requiring key to idx, not sure why my function is missing
- Child object of variable in state does not display
- What should be the type of a RouteComponentProps to add additional attributes under props parameter?
- How to make typesafe-actions work with redux-logic transform?
- Ajax success issue with React and Rails
- Programatically highlight input tags depending on the state value of redux
- i want to return two different response when mocking promise method
- TypeError: props.render is not a function (React hook form)
- How can I sanitize formatted text for any input in React?
- React router not working in very basic way
- What are the valid values for material -ui's Typography component
- React-query + Nextjs using hydration config for SSR doesn't use cached results and always have to wait fetch again
- React-redux check which action was triggred
- the routes change but the pages are not shown in my react app
- React input field states wont update after handleSubmit
- How to solve Stripe elements for react causing memory leak on redirect
- React setting state with async/await
- Image Files in Mongo DB as URI
- React Route shows blank page
- How can you render the array of an API that's inside an object?
- type error extend is not a function in styled components
- How to get normal json object from Promise Object in react-redux
- Matching setState interval with css animation
- React render multiple data based on conditional array
- How to clear the search parameter that caused the error?
- How to send props to components via Link / Routes from react router dom?
- How to create a custom hook that recives dependencies?
- React JS issue when trying to save object / array - Canvas Signature Pad
- Uncaught (in promise) DOMException: Document.querySelector with Google Fonts Link in NextJS
- CORS enable in servlet