DEV Community

Oyeyipo Olawale
Oyeyipo Olawale

Posted on • Updated on

Using passed in props in react class methods

To make use of a prop, passed in or down from a parent component. You first created a constructor for the class. Check the code below:

class SomeClass extends Component {
   Constructor(props) {
       super(props);
       this.props = props; 
   }

   someMethod = () => {
       console.log(this.props)
   }
}
Enter fullscreen mode Exit fullscreen mode

Weird! Thought it will happen some other way.

Top comments (1)

Collapse
 
dance2die profile image
Sung M. Kim

Hi Oyeyipo.

Weird! Thought it will happen some other way.

Which part would you find weird & unintuitve?