question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Warning: This synthetic event is reused for performance reasons

See original GitHub issue

If Redux DevTools 2.11.1.1 are enabled, runtime shows the Errors:

image etc…

Versions of packages

Redux DevTools 2.11.1.1
react@15.4.1
redux@3.6.0
redux-saga@0.14.0

Use case

import env from 'utils/env'
import { createStore, applyMiddleware, compose } from 'redux'
import createSagaMiddleware from 'redux-saga'

const sagaMiddleware = createSagaMiddleware()

const middleware = [ sagaMiddleware ]

let composeEnhancers = compose

// Support Redux DevTools Extension
if (env.isDev && typeof window === 'object') {

	const RDTEC = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__

	if (RDTEC) {

		composeEnhancers = RDTEC({
			// Specify here name, actionsBlacklist, actionsCreators and other options
		})
	}
}

const enhancer = composeEnhancers(
	applyMiddleware(...middleware),
	// other store enhancers if any
)

export default (rootReducer, preloadedState) => {

	rootReducer = rootReducer || function (state) { return state }
	preloadedState = preloadedState || {}

	const store = createStore(rootReducer, preloadedState, enhancer)

	return {
		...store,
		runSaga: sagaMiddleware.run
	}
}

How to fix it?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

20reactions
NGuldagercommented, Jan 6, 2017

I just had this problem myself. I found that my issue was that I passed the synthetic event directly in my action payload.

2reactions
zalmoxisuscommented, Jan 6, 2017

@NGuldager thanks for the clarification.

In this case we’re accessing the event to show it in the monitor. As stated in the warning message from React, the synthetic event cannot be reused for performance reason.

If you still need to pass it to an action, you can override this key of the stringified payload in your action creator, by adding a custom toJSON function (which will be called by the extension before accessing the object):

function increment(event) {
  return {
    type: INCREMENT_COUNTER,
    event,
+   toJSON: function (){
+     return { ...this, event: '[Event]' };
+   }
  };
}

Note that it shouldn’t be arrow function as we want to have access to the function’s this.

As we don’t have access to the original object, skipping and recomputing actions during hot reloading will not work in this case. So better to use the required value from the event than the whole event object.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Warning: This synthetic event is reused for performance ...
This is what React documentation says about it: "The SyntheticEvent is pooled. This means that the SyntheticEvent object will be reused and all ......
Read more >
This synthetic event is reused for performance reasons #451
ERROR Warning: This synthetic event is reused for performance reasons. If you're seeing this, you're accessing the property nativeEvent on a ...
Read more >
React SyntheticEvent reuse - Medium
“Warning: This synthetic event is reused for performance reasons”. This warning is triggered when we try to access to a React synthetic event...
Read more >
event.persist() should be called when using React synthetic ...
React uses the SyntheticEvent objects to wrap native events. For performance reasons, synthetic events are pooled and reused across multiple ...
Read more >
This synthetic event is reused for performance reasons React ...
Coding example for the question Warning: This synthetic event is reused for performance reasons React-Reactjs.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found