score:5
Accepted answer
you can change your code with es2015
like this
class text extends react.component {
constructor() {
super();
this.state = { currenttime: (new date()).tostring() };
}
componentdidmount() {
setinterval(() => this.updatecurrenttime(), 1000);
}
updatecurrenttime() {
this.setstate({
currenttime: (new date()).tostring()
});
}
render() {
return <div>
<span>hello my name is { this.props.name }</span>
<span>and i was born { this.props.startdate }</span>
<span>and i now it's { this.state.currenttime }</span>
</div>
}
};
let paragraph = () => {
return <div classname="mysupertable">
<text name="dodo" startdate={ (new date()).tostring() } />
</div>
};
score:1
as you said, you wanted use es6 as much as possible. so then instead of using createclass, you can use 'react.component', you can find more info here.
and then to use, arrow mark you can use babel, preset-2015.
Source: stackoverflow.com
Related Query
- Unable to use Arrow functions inside React component class
- How to use arrow functions inside React.createClass
- How to use synchronous and asynchronous functions inside onClick method in React
- how react use this keyword in arrow functions
- How do I use arrow functions in React
- React Best Practices: If we can't use arrow functions in JSX onChange( ), how can we pass in custom arguments?
- How to use switch statement inside a React component?
- Correct use of arrow functions in React
- How to avoid bind or inline arrow functions inside render method
- Can I use arrow functions instead of normal functions for React Hooks?
- How to use generics with arrow functions in Typescript/JSX with React?
- How to use material-ui IconMenu inside cell of React fixed-data-table
- how to use a CDN inside a React component
- How to use FormattedMessage inside an option tag in React 0.14?
- How to use Media Queries inside a React Styled Components Keyframe?
- When using React Is it preferable to use fat arrow functions or bind functions in constructor?
- What is the difference between arrow functions and regular functions inside React functional components (no longer using class components)?
- How to use checkbox inside select options? React hook
- How can I use an axios get call inside a Context provider in react
- React how to use icon inside Textfield Material-UI with TypeScript
- How do I test component methods on a React component that are defined as arrow functions (class properties)?
- How to not use setState inside render function in React
- How to use an ejs variable inside a react render function?
- How can one use a polymer component inside a react component ? Is it possible?
- How to use React Context inside function of Class component
- How to use CSS inside a React + Material-UI project?
- How to use react inside a polymer component?
- How to use the global data from React inside Apollo client's initialization?
- How to mock ipcRenderer.on functions inside React functional components
- How to use Stencil's `EventEmitter` inside React JSX?
More Query from same tag
- Switch' is not exported from 'react-router-dom'
- Create dropdown inside table cell using result of string.match()
- Cannot change the background colour of <SideNav>
- How do I convert my class and render() to a functional component using react hooks?
- ReactJs Redirect on state variable change
- How to pass .env variables to .scss file
- Pass data from one dialog to another in React
- how can I scroll component when we are in mobile response
- Map object inside an mapped object
- use api info and equal it to an array
- How to change React parent component size based on child component size without rendering child component?
- React.js: Cancel button is cancelling editing but leaving the state with the changed value after editing was started
- How to update the global state using redux and remove an item from the global state
- Babel Config Error: Support for the experimental syntax 'jsx' isn't currently enabled
- Different colour for react-table headers
- CORS error when making network call in useEffect in Next.Js
- Fastest way to add pre-existing static HTML page to a React/Gatsby site
- Dispatch 2 actions in redux thunk
- Implementing The SliderPicker from react-color library
- Accessing props in onSubmit method of react-dropzone-uploader
- how to put div below header div and above footer div with full height html
- How to handle a 3 levels deep nested multi-step form in React?
- Not able to edit content in textbox when it is derived from this.props.location.state
- How is routing done in react-router-dom version 6?
- Contentful with react expected parameter accessToken error
- Uncaught Error: Cannot find module 'firebase' when trying to use serverTimestamp in firestore
- React webpack app public/images vs src/images
- React Provider (Typescript) value are incompatible
- React: Update state for a particular element
- REACT i'm malding because of "Cannot read property 'map' of undefined"