mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 01:12:56 +03:00
remove the usage of spread operator in setState (#1490)
This commit is contained in:
parent
9b36dca243
commit
ef565590af
@ -17,7 +17,6 @@ class TodoInput extends React.Component {
|
||||
|
||||
handleTextboxValueChange(e) {
|
||||
this.setState({
|
||||
...this.state,
|
||||
textboxValue: e.target.value
|
||||
});
|
||||
}
|
||||
@ -60,7 +59,6 @@ class TodoInput extends React.Component {
|
||||
console.error(e);
|
||||
}
|
||||
this.setState({
|
||||
...this.state,
|
||||
textboxValue: ""
|
||||
});
|
||||
}
|
||||
|
@ -51,7 +51,6 @@ class TodoPublicList extends Component {
|
||||
next(data) {
|
||||
if (data.data.todos.length) {
|
||||
_this.setState({
|
||||
...this.state,
|
||||
showNew: true,
|
||||
newTodosLength:
|
||||
_this.state.newTodosLength + data.data.todos.length
|
||||
@ -69,7 +68,7 @@ class TodoPublicList extends Component {
|
||||
}
|
||||
loadMoreClicked() {
|
||||
const { client } = this.props;
|
||||
this.setState({ ...this.state, showNew: false, newTodosLength: 0 });
|
||||
this.setState({ showNew: false, newTodosLength: 0 });
|
||||
client
|
||||
.query({
|
||||
query: QUERY_FEED_PUBLIC_TODO,
|
||||
@ -81,7 +80,7 @@ class TodoPublicList extends Component {
|
||||
if (data.data.todos.length) {
|
||||
const mergedTodos = data.data.todos.concat(this.state.todos);
|
||||
// update state with new todos
|
||||
this.setState({ ...this.state, todos: mergedTodos });
|
||||
this.setState({ todos: mergedTodos });
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -100,9 +99,9 @@ class TodoPublicList extends Component {
|
||||
if (data.data.todos.length) {
|
||||
const mergedTodos = this.state.todos.concat(data.data.todos);
|
||||
// update state with new todos
|
||||
this.setState({ ...this.state, todos: mergedTodos });
|
||||
this.setState({ todos: mergedTodos });
|
||||
} else {
|
||||
this.setState({ ...this.state, showOlder: false });
|
||||
this.setState({ showOlder: false });
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -110,7 +109,7 @@ class TodoPublicList extends Component {
|
||||
const finalTodos = this.state.todos.filter(t => {
|
||||
return t.id !== deletedTodo.id;
|
||||
});
|
||||
this.setState({ ...this.state, todos: finalTodos });
|
||||
this.setState({ todos: finalTodos });
|
||||
}
|
||||
completePublicTodoClicked(completedTodo) {
|
||||
const finalTodos = this.state.todos.filter(t => {
|
||||
@ -120,7 +119,7 @@ class TodoPublicList extends Component {
|
||||
}
|
||||
return t;
|
||||
});
|
||||
this.setState({ ...this.state, todos: finalTodos });
|
||||
this.setState({ todos: finalTodos });
|
||||
}
|
||||
render() {
|
||||
const { userId, type } = this.props;
|
||||
|
@ -44,7 +44,6 @@ class Chat extends React.Component {
|
||||
// set refetch function (coming from child <Query> component) using callback
|
||||
setRefetch = (refetch) => {
|
||||
this.setState({
|
||||
...this.state,
|
||||
refetch
|
||||
})
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ export default class RenderMessagesProxy extends React.Component {
|
||||
// Set mutation callback. For instantly adding messages to state after mutation
|
||||
setMutationCallback = (mutationCallback) => {
|
||||
this.setState({
|
||||
...this.state,
|
||||
mutationCallback
|
||||
})
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ export default class Main extends React.Component {
|
||||
// set username
|
||||
setUsername = (username) => {
|
||||
this.setState({
|
||||
...this.state,
|
||||
username
|
||||
})
|
||||
}
|
||||
@ -27,7 +26,6 @@ export default class Main extends React.Component {
|
||||
// check usernme and perform login
|
||||
login = (id) => {
|
||||
this.setState({
|
||||
...this.state,
|
||||
isLoggedIn: true,
|
||||
userId: id
|
||||
})
|
||||
|
@ -27,7 +27,6 @@ class OnlineUsers extends React.Component {
|
||||
|
||||
toggleMobileView = () => {
|
||||
this.setState({
|
||||
...this.state,
|
||||
showMobileView: !this.state.showMobileView
|
||||
});
|
||||
}
|
||||
|
@ -95,7 +95,6 @@ export default class RenderMessages extends React.Component {
|
||||
}
|
||||
});
|
||||
this.setState({
|
||||
...this.state,
|
||||
newMessages
|
||||
})
|
||||
}
|
||||
@ -104,7 +103,6 @@ export default class RenderMessages extends React.Component {
|
||||
addOldMessages = (messages) => {
|
||||
const oldMessages = [ ...this.state.messages, ...messages];
|
||||
this.setState({
|
||||
...this.state,
|
||||
messages: oldMessages,
|
||||
newMessages: []
|
||||
})
|
||||
@ -115,7 +113,6 @@ export default class RenderMessages extends React.Component {
|
||||
const messages = [ ...this.state.messages, ...this.state.newMessages ];
|
||||
messages.push(message);
|
||||
this.setState({
|
||||
...this.state,
|
||||
messages,
|
||||
newMessages: []
|
||||
});
|
||||
@ -158,13 +155,11 @@ export default class RenderMessages extends React.Component {
|
||||
const windowBottom = windowHeight + window.pageYOffset;
|
||||
if (windowBottom >= docHeight) {
|
||||
this.setState({
|
||||
...this.state,
|
||||
bottom: true
|
||||
})
|
||||
} else {
|
||||
if (this.state.bottom) {
|
||||
this.setState({
|
||||
...this.state,
|
||||
bottom: false
|
||||
});
|
||||
}
|
||||
@ -211,7 +206,6 @@ export default class RenderMessages extends React.Component {
|
||||
// set refetch in local state to make a custom refetch
|
||||
if (!this.state.refetch) {
|
||||
this.setState({
|
||||
...this.state,
|
||||
refetch
|
||||
});
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ class App extends Component {
|
||||
}
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if ( nextProps.vehicleId !== this.props.vehicleId ) {
|
||||
this.setState({ ...this.state, vehicleId: nextProps.vehicleId });
|
||||
this.setState({ vehicleId: nextProps.vehicleId });
|
||||
}
|
||||
}
|
||||
render() {
|
||||
|
@ -54,7 +54,7 @@ export class MapContainer extends Component {
|
||||
}
|
||||
}
|
||||
handleGoogleMapApi = (google) => {
|
||||
this.setState({ ...this.state, ...google, mapLoaded: true});
|
||||
this.setState({ ...google, mapLoaded: true});
|
||||
const getPolyline = (routeJson) => {
|
||||
var polyline = new google.maps.Polyline({
|
||||
path: [],
|
||||
|
@ -27,7 +27,7 @@ class Vehicle extends Component { constructor() {
|
||||
}
|
||||
updateLocation() {
|
||||
if (locationData.length === this.state.locationId) {
|
||||
this.setState({ ...this.state, locationId: 0 });
|
||||
this.setState({ locationId: 0 });
|
||||
}
|
||||
const insert_vehicle_location = gql`
|
||||
mutation insert_vehicle_location ($objects: [vehicle_location_insert_input!]! ) {
|
||||
@ -52,7 +52,7 @@ class Vehicle extends Component { constructor() {
|
||||
variables: { ...variables },
|
||||
}
|
||||
).then((response) => {
|
||||
this.setState({ ...this.state, locationId: this.state.locationId + 1});
|
||||
this.setState({ locationId: this.state.locationId + 1});
|
||||
|
||||
})
|
||||
.catch((error) => console.error(error));
|
||||
@ -60,11 +60,11 @@ class Vehicle extends Component { constructor() {
|
||||
loadVehicleInfo(e) {
|
||||
const vehicleId = e.target.getAttribute('data-vehicle-id');
|
||||
if ( vehicleId ){
|
||||
this.setState({ ...this.state, vehicleId: parseInt(vehicleId, 10)});
|
||||
this.setState({ vehicleId: parseInt(vehicleId, 10)});
|
||||
}
|
||||
}
|
||||
handleTrackLocationClick() {
|
||||
this.setState({ ...this.state, isLoading: true });
|
||||
this.setState({ isLoading: true });
|
||||
const insert_vehicle = gql`
|
||||
mutation insert_vehicle ($objects: [vehicle_insert_input!]! ) {
|
||||
insert_vehicle (objects: $objects){
|
||||
@ -88,11 +88,11 @@ class Vehicle extends Component { constructor() {
|
||||
variables: { ...variables },
|
||||
}
|
||||
).then((response) => {
|
||||
this.setState({ ...this.state, startTracking: true });
|
||||
this.setState({ startTracking: true });
|
||||
const pollId = setInterval(this.updateLocation.bind(this), this.state.delay);
|
||||
this.setState({ ...this.state, pollId: pollId, isLoading: false });
|
||||
this.setState({ pollId: pollId, isLoading: false });
|
||||
}).catch((error) => {
|
||||
this.setState({ ...this.state, isLoading: false });
|
||||
this.setState({ isLoading: false });
|
||||
console.error(error)
|
||||
});
|
||||
}
|
||||
|
@ -24,18 +24,18 @@ class PollQuestion extends Component {
|
||||
}
|
||||
|
||||
handleOptionChange = (e) => {
|
||||
this.setState({ ...this.state, optionId: e.currentTarget.value });
|
||||
this.setState({ optionId: e.currentTarget.value });
|
||||
}
|
||||
|
||||
onMutationCompleted = () => {
|
||||
this.setState({ ...this.state, voteBtnText: '👍 Done', voteBtnStyle: 'success' });
|
||||
this.setState({ voteBtnText: '👍 Done', voteBtnStyle: 'success' });
|
||||
window.setTimeout(() => {
|
||||
this.setState({ ...this.state, voteBtnText: '🗳️ Vote', voteBtnStyle: 'primary' });
|
||||
this.setState({ voteBtnText: '🗳️ Vote', voteBtnStyle: 'primary' });
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
onMutationError = () => {
|
||||
this.setState({ ...this.state, voteBtnText: 'Error 😞 Try again', voteBtnStyle: 'danger' });
|
||||
this.setState({ voteBtnText: 'Error 😞 Try again', voteBtnStyle: 'danger' });
|
||||
}
|
||||
|
||||
render () {
|
||||
@ -52,10 +52,10 @@ class PollQuestion extends Component {
|
||||
onSubmit={e => {
|
||||
e.preventDefault();
|
||||
if (!this.state.optionId) {
|
||||
this.setState({...this.state, voteBtnText: '✋ Select an option and try again', voteBtnStyle: 'warning'});
|
||||
this.setState({ voteBtnText: '✋ Select an option and try again', voteBtnStyle: 'warning'});
|
||||
return
|
||||
}
|
||||
this.setState({...this.state, voteBtnText: '🗳️ Submitting', voteBtnStyle: 'info'});
|
||||
this.setState({ voteBtnText: '🗳️ Submitting', voteBtnStyle: 'info'});
|
||||
vote({
|
||||
variables: {
|
||||
optionId: this.state.optionId,
|
||||
|
@ -18,7 +18,6 @@ export default class TodoInput extends React.Component {
|
||||
|
||||
handleTextboxValueChange = (e) => {
|
||||
this.setState({
|
||||
...this.state,
|
||||
textboxValue: e.target.value
|
||||
});
|
||||
}
|
||||
@ -44,7 +43,6 @@ export default class TodoInput extends React.Component {
|
||||
data
|
||||
})
|
||||
this.setState({
|
||||
...this.state,
|
||||
textboxValue: ''
|
||||
});
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ class GraphiQLWrapper extends Component {
|
||||
: null;
|
||||
if (queryFile) {
|
||||
getRemoteQueries(queryFile, queries =>
|
||||
this.setState({ ...this.state, queries })
|
||||
this.setState({ queries })
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class LoginComponent extends React.Component {
|
||||
this.state = { graphqlEndpoint: '' };
|
||||
}
|
||||
setGraphQLEndpoint(e) {
|
||||
this.setState({ ...this.state, graphqlEndpoint: e.target.value });
|
||||
this.setState({ graphqlEndpoint: e.target.value });
|
||||
}
|
||||
render() {
|
||||
const { dispatch } = this.props;
|
||||
|
@ -28,9 +28,7 @@ class GraphiQLWrapper extends Component {
|
||||
? this.props.queryParams.query_file
|
||||
: null;
|
||||
if (queryFile) {
|
||||
getRemoteQueries(queryFile, queries =>
|
||||
this.setState({ ...this.state, queries })
|
||||
);
|
||||
getRemoteQueries(queryFile, queries => this.setState({ queries }));
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,13 +81,11 @@ class GraphiQLWrapper extends Component {
|
||||
}
|
||||
updateAnalyzeState(supportAnalyze) {
|
||||
this.setState({
|
||||
...this.state,
|
||||
supportAnalyze: supportAnalyze,
|
||||
});
|
||||
}
|
||||
updateAnalyzeApiState(analyzeApiChange) {
|
||||
this.setState({
|
||||
...this.state,
|
||||
analyzeApiChange: analyzeApiChange,
|
||||
});
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ export default class InputChecker extends React.Component {
|
||||
e.target && parseInt(e.target.getAttribute('data-index-id'), 10);
|
||||
if (!val) {
|
||||
this.setState({
|
||||
...this.state,
|
||||
isError: false,
|
||||
errorMessage: '',
|
||||
});
|
||||
@ -26,7 +25,6 @@ export default class InputChecker extends React.Component {
|
||||
inputChecker(this.props.type, val)
|
||||
.then(r => {
|
||||
this.setState({
|
||||
...this.state,
|
||||
isError: false,
|
||||
errorMessage: '',
|
||||
});
|
||||
@ -34,7 +32,6 @@ export default class InputChecker extends React.Component {
|
||||
})
|
||||
.catch(r => {
|
||||
this.setState({
|
||||
...this.state,
|
||||
isError: true,
|
||||
errorMessage: r.message,
|
||||
});
|
||||
|
@ -71,7 +71,7 @@ class Main extends React.Component {
|
||||
this.props.serverVersion
|
||||
);
|
||||
if (showSchemaStitch) {
|
||||
this.setState({ ...this.state, showSchemaStitch: true });
|
||||
this.setState({ showSchemaStitch: true });
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
@ -102,7 +102,6 @@ class Main extends React.Component {
|
||||
};
|
||||
setLoveConsentState(s);
|
||||
this.setState({
|
||||
...this.state,
|
||||
loveConsentState: { ...getLoveConsentState() },
|
||||
});
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ class Edit extends React.Component {
|
||||
}
|
||||
}
|
||||
updateDeleteConfirmationError(data) {
|
||||
this.setState({ ...this.state, deleteConfirmationError: data });
|
||||
this.setState({ deleteConfirmationError: data });
|
||||
}
|
||||
modifyClick() {
|
||||
this.props.dispatch({ type: TOGGLE_MODIFY });
|
||||
|
@ -46,7 +46,7 @@ class ModifyCustomFunction extends React.Component {
|
||||
]);
|
||||
}
|
||||
updateDeleteConfirmationError(data) {
|
||||
this.setState({ ...this.state, deleteConfirmationError: data });
|
||||
this.setState({ deleteConfirmationError: data });
|
||||
}
|
||||
handleUntrackCustomFunction(e) {
|
||||
e.preventDefault();
|
||||
|
@ -42,7 +42,6 @@ class Metadata extends Component {
|
||||
}
|
||||
updateMetadataState(displayReloadMetadata) {
|
||||
this.setState({
|
||||
...this.state,
|
||||
showMetadata: displayReloadMetadata,
|
||||
});
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ class InsertItem extends Component {
|
||||
// Since the state variable lifecycle is tired to the instance of the class
|
||||
// and making this change using an anonymous function will case errors.
|
||||
this.setState({
|
||||
...this.state,
|
||||
insertedRows: this.state.insertedRows + 1,
|
||||
});
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ class Permissions extends Component {
|
||||
)
|
||||
.then(r => {
|
||||
if (r.length > 0) {
|
||||
this.setState({ ...this.state, viewInfo: r[0] });
|
||||
this.setState({ viewInfo: r[0] });
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -174,7 +174,6 @@ class Permissions extends Component {
|
||||
});
|
||||
|
||||
this.setState({
|
||||
...this.state,
|
||||
insertSetOperations: {
|
||||
...this.state.insertSetOperations,
|
||||
columnTypeMap: {
|
||||
@ -210,14 +209,12 @@ class Permissions extends Component {
|
||||
showAggregation = semverCheck('aggregationPerm', version);
|
||||
showUpsertSection = !semverCheck('permHideUpsertSection', version);
|
||||
this.setState({
|
||||
...this.state,
|
||||
showAggregation,
|
||||
showUpsertSection,
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
this.setState({
|
||||
...this.state,
|
||||
showAggregation: false,
|
||||
showUpsertSection: false,
|
||||
});
|
||||
@ -229,13 +226,13 @@ class Permissions extends Component {
|
||||
try {
|
||||
showInsertPrefix = semverCheck('insertPrefix', version);
|
||||
if (showInsertPrefix) {
|
||||
this.setState({ ...this.state, showInsertPrefix: true });
|
||||
this.setState({ showInsertPrefix: true });
|
||||
} else {
|
||||
this.setState({ ...this.state, showInsertPrefix: false });
|
||||
this.setState({ showInsertPrefix: false });
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
this.setState({ ...this.state, showInsertPrefix: false });
|
||||
this.setState({ showInsertPrefix: false });
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
@ -83,13 +83,12 @@ class AddTrigger extends Component {
|
||||
|
||||
checkWebhookEnvSupport(version) {
|
||||
const supportWebhookEnv = semverCheck('webhookEnvSupport', version);
|
||||
this.setState({ ...this.state, supportWebhookEnv });
|
||||
this.setState({ supportWebhookEnv });
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
updateSupportColumnChangeFeature(val) {
|
||||
this.setState({
|
||||
...this.state,
|
||||
supportColumnChangeFeature: val,
|
||||
});
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ class Editor extends React.Component {
|
||||
this.props.toggleCallback();
|
||||
}
|
||||
this.setState({
|
||||
...this.state,
|
||||
isEditing: !this.state.isEditing,
|
||||
});
|
||||
};
|
||||
|
@ -64,13 +64,13 @@ class StreamingLogs extends Component {
|
||||
try {
|
||||
showRedeliver = semverCheck('eventRedeliver', version);
|
||||
if (showRedeliver) {
|
||||
this.setState({ ...this.state, showRedeliver: true });
|
||||
this.setState({ showRedeliver: true });
|
||||
} else {
|
||||
this.setState({ ...this.state, showRedeliver: false });
|
||||
this.setState({ showRedeliver: false });
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
this.setState({ ...this.state, showRedeliver: false });
|
||||
this.setState({ showRedeliver: false });
|
||||
}
|
||||
}
|
||||
handleNewerEvents() {
|
||||
|
@ -53,11 +53,11 @@ class RedeliverEvent extends Component {
|
||||
() => this.props.dispatch(loadEventInvocations(eventId)),
|
||||
5000
|
||||
);
|
||||
this.setState({ ...this.state, intervalId: intervalId });
|
||||
this.setState({ intervalId: intervalId });
|
||||
}
|
||||
removeFetching(intervalId) {
|
||||
clearInterval(intervalId);
|
||||
this.setState({ ...this.state, intervalId: null });
|
||||
this.setState({ intervalId: null });
|
||||
}
|
||||
refreshData() {
|
||||
this.props.dispatch(loadEventInvocations(this.props.log.event_id));
|
||||
@ -230,10 +230,10 @@ class RedeliverEvent extends Component {
|
||||
value={
|
||||
log.eventInvocations[0]
|
||||
? JSON.stringify(
|
||||
log.eventInvocations[0].request,
|
||||
null,
|
||||
4
|
||||
)
|
||||
log.eventInvocations[0].request,
|
||||
null,
|
||||
4
|
||||
)
|
||||
: ''
|
||||
}
|
||||
minLines={8}
|
||||
|
Loading…
Reference in New Issue
Block a user