28
loading...
This website collects cookies to deliver better user experience
You clicked {count} times
example').constructor(props) {
super(props);
this.state = {
currentPageBuilds: [],
downloadedData: [],
filteredData: [],
builds: [],
_sort: 'submittedDate',
_page: 1,
_order: 'desc',
_limit: 10,
_Type: 0,
_boxId: '',
boxName: '',
selectedRows: { data: [] },
q: '',
totalCount: 0,
loading: false,
isFiltered: false,
failure: false,
};
import React,{useState} from 'react'
/*here we have imported the useState to maintain the state of the React component.
*/
import React,{useState} from 'react'
function State() {
return (
<div>
</div>
)
}
export default State
const [characters, setCharactersData] = useState([]);
import "./styles.css";
import React, { useState } from "react";
export default function App() {
const [characters, setCharactersData] = useState([]);
const fetchData = async () => {
await fetch("https://mocki.io/v1/d4867d8b-b5d5-4a48-a4ab-79131b5809b8")
.then((res) => res.json())
.then((data) => {
let names = [];
data.forEach(function (item) {
names.push(item.name)
});
setCharactersData(names);
});
};
return (
<div>
<label>Data is</label>
<p>{characters}</p>
<button onClick={() => fetchData()}>Click</button>
</div>
);
}
const [multiple, setMultiple] = useState({currentPageBuilds: [],
downloadedData: [],
filteredData: [],
builds: [],
_sort: 'submittedDate',
_page: 1,
_order: 'desc',
_limit: 10,
_Type: 0,
_boxId: '',
boxName: '',
selectedRows: { data: [] },
q: '',
totalCount: 0,
loading: false,
isFiltered: false,
failure: false,});
setMultiple({...multiple,failure:true});
setMessage(previousVal => previousVal + currentVal)