question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support (or sort of) for Functional component

See original GitHub issue

Here is a simple functional component

/* @flow */

import React, { Element } from "react"

type Props = {
  param: string,
}

const ReactFunctionalComponent = (props: Props): Element => {
  return (
    <div>
      { props.param }
    </div>
  )
}

export default ReactFunctionalComponent

Flow: ok eslint (with plugin react): ok

but this plugin seems to raise an error

babel-plugin-flow-react-proptypes: Encountered an unknown node in the type definition Node {
  type: 'FunctionTypeAnnotation',
  start: 91,
  end: 101,
  loc: 
   SourceLocation {
     start: Position { line: 6, column: 12 },
     end: Position { line: 6, column: 22 } },
  params: [],
  rest: null,
  returnType: 
   Node {
     type: 'VoidTypeAnnotation',
     start: 97,
     end: 101,
     loc: SourceLocation { start: [Object], end: [Object] } },
  typeParameters: null }
/Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-core/lib/transformation/file/index.js:556
      throw err;
      ^

Error: /Users/MoOx/Sync/Development/js-boilerplate/src/ReactClass/index.js: babel-plugin-flow-react-proptypes processing error
    at convertToPropTypes (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-plugin-flow-react-proptypes/lib/convertToPropTypes.js:65:11)
    at /Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-plugin-flow-react-proptypes/lib/convertToPropTypes.js:22:15
    at Array.map (native)
    at convertToPropTypes (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-plugin-flow-react-proptypes/lib/convertToPropTypes.js:17:31)
    at PluginPass.TypeAlias (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-plugin-flow-react-proptypes/lib/index.js:29:25)
    at newFn (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-traverse/lib/visitors.js:262:19)
    at NodePath._call (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-traverse/lib/path/context.js:63:18)
    at NodePath.call (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-traverse/lib/path/context.js:47:17)
    at NodePath.visit (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-traverse/lib/path/context.js:93:12)
    at TraversalContext.visitQueue (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-traverse/lib/context.js:152:16)
    at TraversalContext.visitMultiple (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-traverse/lib/context.js:110:17)
    at TraversalContext.visit (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-traverse/lib/context.js:182:19)
    at Function.traverse.node (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-traverse/lib/index.js:135:17)
    at NodePath.visit (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-traverse/lib/path/context.js:103:22)
    at TraversalContext.visitQueue (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-traverse/lib/context.js:152:16)
    at TraversalContext.visitSingle (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-traverse/lib/context.js:115:19)
    at TraversalContext.visit (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-traverse/lib/context.js:184:19)
    at Function.traverse.node (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-traverse/lib/index.js:135:17)
    at Object.traverse [as default] (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-traverse/lib/index.js:69:12)
    at /Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-core/lib/transformation/file/index.js:513:33
    at Array.forEach (native)
    at File.transform (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-core/lib/transformation/file/index.js:510:23)
    at /Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-core/lib/transformation/pipeline.js:49:19
    at File.wrap (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-core/lib/transformation/file/index.js:528:16)
    at Pipeline.transform (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-core/lib/transformation/pipeline.js:46:17)
    at Object.transformFileSync (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-core/lib/api/node.js:124:10)
    at compile (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-register/lib/node.js:98:20)
    at loader (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-register/lib/node.js:126:14)
    at require.extensions.(anonymous function) (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/babel-register/lib/node.js:136:7)
    at extensions.(anonymous function) (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/require-precompiled/index.js:16:3)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/ava/lib/test-worker.js:99:3)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.<anonymous> (/Users/MoOx/Sync/Development/js-boilerplate/src/ReactClass/__tests__/index.js:10:1)
    at Module._compile (module.js:413:34)
    at extensions.(anonymous function) (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/require-precompiled/index.js:13:11)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/ava/lib/test-worker.js:99:3)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.<anonymous> (/Users/MoOx/Sync/Development/js-boilerplate/node_modules/ava/lib/test-worker.js:103:1)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.Module.runMain (module.js:447:10)
    at startup (node.js:141:18)
    at node.js:933:3

I understand that it’s not easy to handle this, but at least maybe this should not throw an error?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
brigandcommented, Mar 25, 2016

Fixed, thanks for reporting and trying out the plugin 😃

1reaction
MoOxcommented, Mar 25, 2016

No rush, I was just reporting 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Functional Components: In-Depth Guide
Functional component is just a simple javascript function; it accepts the data in the form of props and returns the react element. Whereas...
Read more >
React component guide: Class vs functional
Using code examples, we'll look at what React components do, compare class and functional components, and discuss which type you should use.
Read more >
How to Use Functional Components in React
Have you wondered how to create a component in React? To answer, it is as simple as creating a function returning an HTML-like...
Read more >
What type of components should I use in React: functional ...
I prefer class based component since I am angular developer and I find it more comfortable to work with these type of components....
Read more >
Understanding Functional Components vs. Class ...
This article will help you understand the differences between functional and class components by walking through each one with sample code ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found