New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applying eight codemods to migrate to esnext and latest react patterns. #1

Open
wants to merge 1 commit into
base: master
from
Jump to file or symbol
Failed to load files and symbols.
+42 −37
Diff settings

Always

Just for now

Copy path View file
@@ -1,63 +1,68 @@
import React from 'react'
var Car = ({ value, onClick }) => <div onClick={onClick}>{value}</div>
var CarList = React.createClass({
getInitialState: function() {
return {
cars: [
'Volvo',
'Saab',
'BMW',
'Tesla',
'Mercedes',
'Fiat',
'Renault',
'Lada',
'Opel'
],
selectedCar: null,
history: null
}
},
class Car extends Component {
render() {
return <div onClick={onClick}>{value}</div>;
}
}
class CarList extends React.Component {
state = {
cars: [
'Volvo',
'Saab',
'BMW',
'Tesla',
'Mercedes',
'Fiat',
'Renault',
'Lada',
'Opel',
],
selectedCar: null,
history: null
};
setSelectedCar: function(selectedCar) {
setSelectedCar = (selectedCar) => {
this.setState(state => ({
selectedCar: selectedCar,
history: Object.assign({}, state.history, selectedCar.id)
selectedCar,
history: {
...state.history,
...selectedCar.id
}
}))
},
};
renderCars: function() {
var cars = this.cars.map(car => (
renderCars = () => {
const cars = this.cars.map(car => (
<Car
value={car}
onClick={function(e) {
onClick={e => {
this.setSelectedCar(e.target.value)
}.bind(this)}
}}
/>
))
));
return cars
},
};
renderBestCarMessage: function() {
var message = 'No cars'
renderBestCarMessage = () => {
let message = 'No cars';
if (cars.length) {
var randomCar = null
message = 'The best car is ' + randomCar
const randomCar = null;
message = `The best car is ${randomCar}`
}
return message
},
};
render: function() {
render() {
return (
<div>
{this.renderCars()}
{this.renderBestCarMessage()}
</div>
)
}
})
}
export default CarList
ProTip! Use n and p to navigate between commits in a pull request.