Parse Error: Adjacent JSX elements must be wrapped in an enclosing tag

You should put your component between an enclosing tag, Which means: // WRONG! return ( <Comp1 /> <Comp2 /> ) Instead: // Correct return ( <div> <Comp1 /> <Comp2 /> </div> ) Edit: Per Joe Clay’s comment about the Fragments API // More Correct return ( <React.Fragment> <Comp1 /> <Comp2 /> </React.Fragment> ) // Short … Read more

Pros/cons of using redux-saga with ES6 generators vs redux-thunk with ES2017 async/await

In redux-saga, the equivalent of the above example would be export function* loginSaga() { while(true) { const { user, pass } = yield take(LOGIN_REQUEST) try { let { data } = yield call(request.post, ‘/login’, { user, pass }); yield fork(loadUserData, data.uid); yield put({ type: LOGIN_SUCCESS, data }); } catch(error) { yield put({ type: LOGIN_ERROR, error … Read more

The useState set method is not reflecting a change immediately

Much like .setState() in class components created by extending React.Component or React.PureComponent, the state update using the updater provided by useState hook is also asynchronous, and will not be reflected immediately. Also, the main issue here is not just the asynchronous nature but the fact that state values are used by functions based on their … Read more

React JSX: selecting “selected” on selected option

React makes this even easier for you. Instead of defining selected on each option, you can (and should) simply write value={optionsState} on the select tag itself: <select value={optionsState}> <option value=”A”>Apple</option> <option value=”B”>Banana</option> <option value=”C”>Cranberry</option> </select> For more info, see the React select tag doc. Also, React automatically understands booleans for this purpose, so you can … Read more

Correct modification of state arrays in React.js

The React docs says: Treat this.state as if it were immutable. Your push will mutate the state directly and that could potentially lead to error prone code, even if you are “resetting” the state again afterwards. For example, it could lead to that some lifecycle methods like componentDidUpdate won’t trigger. The recommended approach in later … Read more

How to update nested state properties in React

In order to setState for a nested object you can follow the below approach as I think setState doesn’t handle nested updates. var someProperty = {…this.state.someProperty} someProperty.flag = true; this.setState({someProperty}) The idea is to create a dummy object perform operations on it and then replace the component’s state with the updated object Now, the spread … Read more

Error message “error:0308010C:digital envelope routines::unsupported”

Here are two options now – 1. Try to uninstall Node.js version 17+ and reinstall Node.js version 16+ You can re install the current LTS Node.js version from their official site. Or more specific downloads from here; You can use NVM (Node Version Manager) Linux and Mac users can use this nvm package – https://github.com/nvm-sh/nvm … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)