JSFiddle - React, Tailwind, and code Playground
JavaScript
import React from 'react';
import './App.css';
/**
* @return {object}
*/
class App extends React.Component {
/**
* @param {*} props
*/
constructor(props) {
super(props);
this.state = {
items: [
{id: 0, value: 'a'},
{id: 1, value: 'a'},
],
};
this.updateItem(0, 'test');
console.log(this.state.items[0].value);
}
/**
* @return {object}
*/
render() {
return (
<div>
hello world
</div>
);
}
/**
* @p..;@param {*} value
*/
updateItem(id, value) {
this.setState({
items: this.state.items.map((el) => (el.id === id ? {...el, value} : el)),
});
}
}