Await is a reserved word error inside async function

In order to use await, the function directly enclosing it needs to be async. According to your comment, adding async to the inner function fixes your issue, so I’ll post that here: export const sendVerificationEmail = async () => async (dispatch) => { try { dispatch({ type: EMAIL_FETCHING, payload: true }); await Auth.sendEmailVerification(); dispatch({ type: … Read more

Why is my onClick being called on render? – React.js

You need pass to onClick reference to function, when you do like this activatePlaylist( .. ) you call function and pass to onClick value that returned from activatePlaylist. You can use one of these three options: 1. using .bind activatePlaylist.bind(this, playlist.playlist_id) 2. using arrow function onClick={ () => this.activatePlaylist(playlist.playlist_id) } 3. or return function from … Read more

What is the best way to access redux store outside a react component?

Export the store from the module you called createStore with. Then you are assured it will both be created and will not pollute the global window space. MyStore.js const store = createStore(myReducer); export store; or const store = createStore(myReducer); export default store; MyClient.js import {store} from ‘./MyStore’ store.dispatch(…) or if you used default import store … Read more

Load images based on dynamic path in ReactJs

Assuming that you are using webpack, you need to import the image in order to display it like <img src={require(‘images/06.jpg’)} alt=”product” /> Now that your image data is dynamic, directly specifying the import path like <img src={require(image)} alt=”product” /> doesn’t work. However you can import the image by making use of template literals like <img … Read more

How can I display a modal dialog in Redux that performs asynchronous actions?

The approach I suggest is a bit verbose but I found it to scale pretty well into complex apps. When you want to show a modal, fire an action describing which modal you’d like to see: Dispatching an Action to Show the Modal this.props.dispatch({ type: ‘SHOW_MODAL’, modalType: ‘DELETE_POST’, modalProps: { postId: 42 } }) (Strings … Read more