score:24
as explained by nicholas tower in this answer typescript | warning about missing return type of function, eslint, depending on the react version that you are using, you can use any of the lines below:
if you're on the latest react version (16.8.0 or later), do this:
const component: react.functioncomponent<props> = (props: props) => { }
prior to 16.8, you'd instead do:
const component: react.sfc<props> = (props: props) => {}
where sfc stands for "stateless functional component".
edit:------
based on @sergiop's comment, a more idiomatic solution would be
const test = ({ title }: props): jsx.element => <div>{title}</div>
score:3
i too faced this issue.
const handlelogout = () => {
router.push('/')
}
the above code given same issue to me, then code is updated like below, then error disappear in my case
const handlelogout = (): void => {
router.push('/')
}
reference link: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-function-return-type.md
Source: stackoverflow.com
Related Query
- ESLint - missing return type on function react component - Typescript error explanation
- Missing return type on function - in react (typescript) code
- Typescript throws an explicit function return type error when using Suspense with React Router
- Missing return type on a function which returns a React Fragment
- Typescript | Warning about Missing Return Type of function, ESLint
- How to define an interface for React function component with defaultProps without throwing missing type error?
- While using useEffect and unsubscribe, it gives Missing return type on function warning
- What would be the return type for React function
- React Hook Warnings for async function in useEffect: useEffect function must return a cleanup function or nothing
- React eslint error missing in props validation
- What is the TypeScript return type of a React stateless component?
- React with Typescript - Type { } is missing the following properties from type
- Return DOM element in render function of React component
- React Use RouteComponentProps - Type '{}' is missing the following properties from type 'Readonly<RouteComponentProps<{}
- "Missing return type on function" for every React class method
- Function lacks ending return statement and return type does not include 'undefined'
- React: Missing return type on function. eslint(@typescript-eslint/explicit-function-return-type)
- What is the Flow return type of a React stateless functional component?
- Using JS React component in TypeScript: JSX element type 'MyComponent' is not a constructor function for JSX elements
- Assigning type to a React SFC function declaration in TypeScript
- React - cannot be used as a JSX component. Its return type 'void' is not a valid JSX element
- React Typescript Type Cast Issue - Parsing Error: Missing Semicolon
- React redux typescript: connect has missing type error
- Can a cellRenderer function in ag-Grid return a React component?
- How to return a React memoized callback from factory function
- How can I use an IIFE in the return function of a react component?
- Test return value of function with Jest in React
- Optional function prop in React component Flow type check fail
- How to use React.FC<props> type when the children can either be a React node or a function
- React eslint error:Component definition is missing display name
More Query from same tag
- React app failed to load resource: the server responded with a status of 404 GraphQL
- How to re-render component on url change
- All child components are re-rendered when push to props array
- how to make fixed marker in center of google map in react?
- How to download and upload zip file without saving to disk
- How to import image (.svg, .png ) in a React Component
- useSelector hook for functions?
- ./src/index.js Line 10: 'elementid' is not defined no-undef
- Add CSS to react created elements like data-reactroot
- How to retain object attributes when re-ordering with dragula?
- conditionally submitting form depending on state of inputs
- Reactjs implementation of WebAssembly
- ReactJS event works sometimes, sometimes doesn't
- Wait until `this.state` has been set for time period before running function
- After test:report:chrome Report generation done, Terminal not closing the instance, it keeps running
- ReferenceError while using HashHistory
- Document listener exhibiting unusual behaviour
- How to clear selected value from dynamic select dropdown in react?
- Replace an element in an array state (and benefit from ReactJS fast rendering)
- this.setState() does not work in componentWillReceiveProps
- gatsbys onClickOut is not defined
- I can't style a react-router-dom Link using Glamorous
- React - compounding components (Objects are not valid as a React child)
- Dispatching an action isn't setting redux with result
- React hook form and Chakra
- refetching a query with react-apollo: why is `loading` not true?
- Why is my component not rendering?
- React: Changing State in functional component also Change functional component's props value, and its Parent Class State
- Sum of an array from json data
- How to get the times of render with jest/enzyme?