A
A
AnjeyTsibylskij2017-01-03 21:34:38
JavaScript
AnjeyTsibylskij, 2017-01-03 21:34:38

Issues with ReactJS. How to decide?

I started learning React and there were problems that I can’t find a solution for a couple of days.
I do all the manipulations with this code

import React, {Component} from 'react';
import {render} from 'react-dom';

import injectTapEventPlugin from 'react-tap-event-plugin';
injectTapEventPlugin();

class App extends Component {
    onClickHandler(e){
        console.log('click', e);
    }

    onTouchTapHandler(){
        console.log('touch', e);
    }

    render(){
        return (
            <button onClick={this.onClickHandler} onTouchTap={this.onTouchTapHandler}>Test</button>
        );
    }
}

render(<App />, document.getElementById('page'));

  1. Wrote a simple component that displays a button on a page. After that I want to build a script for production, I used the best practices for webpack and I get the following error in the console output
    Uncaught Error: Minified React error #37; visit facebook.github.io/react/docs/error-decoder.html?i... for the full message or use the non-minified dev environment for full errors and additional helpful warnings
    60cdde6ec22446b4a7d9c722f84a5c9e.png
    As I understand it, this is something to do with minification. Please clarify this point for me.
  2. There is a react-tap-event-plugin plugin that adds click events for mobile devices, and so, in all the articles, and in the example on GitHub itself, it says to do this
    import injectTapEventPlugin from 'react-tap-event-plugin';
    injectTapEventPlugin();

    I do everything as in the example, but I still get an error
    Warning: Unknown prop `onTouchTap` on tag. Remove this prop from the element. For details, see https://fb.me/react-unknown-prop
    c716c552ce1e44e2b5d5213bb81a0e9e.png

There is not a single question on this topic on the Toaster, I hope everything works for everyone, and you will tell me where to go

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Masterov, 2017-01-03
@AlexMasterov

1. minimum working example: (see comment to answer)

git clone -b stack/material-ui https://github.com/AlexMasterov/webpack-kit.git material-ui-example
cd material-ui-example
yarn install & yarn serve

http://localhost:3000

2. injectTapEventPlugin add to the constructor:
class App extends Component {
  constructor(props) {
    injectTapEventPlugin();
    super(props);
  }

K
kahi4, 2017-01-03
@kahi4

The second one has already been answered. Regarding the first one: we open the link given to us by the react itself, read it, understand that we need to turn off the production mod in the webpack in development mode (if you don’t know how to do it yet, just delete the line

new webpack.DefinePlugin({
      'process.env':{
        'NODE_ENV': JSON.stringify('production')
      }
    }),,```

He writes what he doesn't like.
PS If the question is why this happens in principle, then the answer is written inside this very link. In short: to optimize the package size, in production mode, all error descriptions are removed inside react, so it throws a standard (this) error on all arising ones.
In your particular case, the error is:
Which is probably due to the fact that it
returns undefined (that is, there is no such id on the page, which, by the way, is true, judging by the repository that you threw off. Yours is not #page, but #app.)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question