score:0
you need a transpiler that converts it to es5, afterwards pipe it in the gulp task. i use babel and there is a gulp-babel npm package
score:0
i changed my code to this, when using the older version the transpiling works. import react from 'react' throws an error.
// var react = require('react');
import react from 'react';
class udpcomp extends react.component {
constructor (props){
super(props);
this.state = { udpinput: this.props.udpinput };
}
render () {
return(
<div classname="udptext">
<h2>udp-input: {this.state.udpinput}</h2>
</div>
) // return
} // render
}; // udpcomp
module.exports = udpcomp;
// export default udpcomp;
score:1
can't see what's on line 14 but i'd guess it's the comma right after your constructor. as opposed to es5 "classes", es6 classes don't require (and don't allow) commas between methods. just remove it and it should work (or at least get past line 14)
Source: stackoverflow.com
Related Query
- gulp converting React module to class error
- How to resolve `this` in converting React module to ES6 class
- Converting class component to functional component using react hooks (useRef)—how to avoid "undefined" error
- React Todo App I get an error while converting class components to functional components
- React syntax error while converting jsx to js using Gulp
- Converting React Class to Functional Components with Hooks. How to fix "uncontrolled input" error
- Converting class to function React Error invalid hook call
- React Native Error Cannot find module 'metro-config/src/defaults/blacklist'
- Converting React function component to class component issue
- Tailwind in React project - getting "Cannot find module 'autoprefixer'" error during setup
- React build issue, ERROR in ./src/index.js Module build failed (from ./node_modules/babel-loader/lib/index.js):
- Cannot call a class as a function, React router show error in console if i use es6 format
- How to fix React Native error "jest-haste-map: Haste module naming collision"?
- Firebase-Admin, importing it to react application throws Module not found error
- react native sudden Unable to resolve module `fs` error
- Module not found error using Yarn 2 to link React components
- Why does React throw an error when setState method used in a class constructor?
- React hot module replacement alternative - Rollup, Gulp and Browsersync
- React component function returning JSX causes error when used in render method of ES6 class React component
- connect react redux HOC got error of `Cannot call a class as a function`
- React + ApolloProvider + Typescript = "JSX element class does not support attributes" error
- Converting JavaScript code to react component class format
- Converting a React Class Component to Function Component
- React component vis-force module error
- getting error : Could not find a declaration file for module 'react-bootstrap-modal'. in react js
- Converting React class with "static get defaultProps()" to functional component
- react storybook jest snapshots leads to an error Cannot find module '../../package' from 'node.js'
- Converting dash's(plotly) react functional component into class component
- how to solve the error that fs module is not found when used react and next.js
- React HOC has a Typescript error as a class component but not as a function component
More Query from same tag
- How can i deepclone an object which has a react.element
- How to force specific type of HTML tag in the component interface
- 'BUILD_PATH' is not recognized as an internal or external command
- Why am I getting Invariant Violation: Invariant Violation: Maximum update depth exceeded. on setState?
- React include a onClick to a span
- how to call child component callback event from parent component in react
- Pass the key value pair to an API in React JS?
- React router - get route prop outside of bound component
- TypeScript - Combining multiple interfaces into just one
- How to update state using settimeout function inside loop in react?
- Dynamic Page according to React-Redux state not updating rendered data
- Unable to handle error from server side of my Application
- How to add a linear gradient to a background image in ReactJs
- React - prevent calling useEffect for the first mount
- ReactJS & Material-UI: How to highlight just content inside Material-UI's <Dialog> and not the whole page?
- MUI Input doesn't allow oninput attribute
- I can't access a key from a JSON response but can see all its keys
- TS2339: Property 'whyDidYouRender' does not exist on type 'FC<ButtonProps>'
- How to finish all fetch before executing next function in React?
- React select custom input won't hide placeholder
- Navigation bar Displaying incorrect
- Facebook React: Uncaught Error: Invariant Violation: getDOMNode(): A component must be mounted to have a DOM node
- how to re-render React component each and every time freshly with animation
- Cannot access this.props from string to function
- Cannot read properties of undefined (reading 'indexOf') with Firebase v9 Modular React JS
- How to insert data from client to server using socket.io?
- Adding ReactJS to a project without npm start
- Counting duplicates in object array and storing the count as a new object have error !!! react js
- How to disable the react leaflet zoom
- React scroll to bottom of Element without scrolling iFrame parent