Creating custom function in React component

前端 未结 4 679
南旧
南旧 2021-01-30 19:58

I have a React component

export default class Archive extends React.Component { 
   ...
}

componentDidMount and onClick

4条回答
  •  猫巷女王i
    2021-01-30 20:54

    You can try this.

    // Author: Hannad Rehman Sat Jun 03 2017 12:59:09 GMT+0530 (India Standard Time)
    
    import React from 'react';
    import RippleButton from '../../Components/RippleButton/rippleButton.jsx';
    
    class HtmlComponents extends React.Component {
    
        constructor(props){
            super(props);
            this.rippleClickFunction=this.rippleClickFunction.bind(this);
        }
    
        rippleClickFunction(){
            //do stuff. 
            // foo==bar
        }
    
        render() {
          return (
             

    React Components

    ); } } export default HtmlComponents;

    Yhe only concern is you have to bind the context to the function

提交回复
热议问题