Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebStorm highlights React component when props passed through react-redux connect function

I have a container component:

import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';

class MyComponent extends Component {
  static propTypes = {
     someEntities: PropTypes.object.isRequired
  }
  ....
}

export default connect(state => ({ someEntities: state.someEntities })(MyComponent)

So I am passing props via connect to this component, but when I place component in code, like:

....
import MyComponent from './MyComponent';
....
<div><MyComponent /></div>
....

WebStorm highlights MyComponent and gives me an error: Element MyComponent doesn't have required attribute someEntities.

I am using version 2016.3.1. Is this an error? Should I use propTypes in this case?

like image 366
Sergey Tyupaev Avatar asked Feb 16 '17 10:02

Sergey Tyupaev


People also ask

How to get data from the Redux store in react?

Whether you want to get data from the Redux store, dispatch actions on the Redux store, or do both in your React component, you can make the component a container component by wrapping it in a higher order component returned by connect():

What is the use of connect in react?

Overview The connect () function connects a React component to a Redux store. It provides its connected component with the pieces of the data it needs from the store, and the functions it can use to dispatch actions to the store.

Can I use Redux with react hooks in functional components?

As of version 7.1, Redux supports React Hooks, meaning you can use Redux with Hooks in your functional components instead of using Redux connect(). With that said, it’s useful to understand the core concept of separating business logic from presentational components because it can simplify solving a lot of complex problems.

Does WebStorm support auto-completion for react-specific attributes?

For example: In JSX tags, WebStorm provides coding assistance for React-specific attributes, such as className or classID, and non-DOM attributes, such as key or ref. Moreover, auto-completion also works for names of classes defined in the project’s CSS files:


1 Answers

This is a known issue, tracked as WEB-21692; please follow it for updates (https://intellij-support.jetbrains.com/hc/en-us/articles/207241135-How-to-follow-YouTrack-issues-and-receive-notifications)

like image 174
lena Avatar answered Oct 12 '22 04:10

lena