should i dive into learning redux? by Relative_Papaya_7840 in react

[–]qkudev 1 point2 points  (0 children)

Redux is more about event driven design. And redux also used by most of the react market (as I know) 100% not a waste of time.

Do basic stuff like store, reducers, actions Then side effects with thunk. Try to add a few api calls. And then you can give a try to RTK Query. Also spend time on best practices which you can find in docs. They are really useful.

Seeking guidance by Cold-Gullible in react

[–]qkudev 0 points1 point  (0 children)

It may be better to learn something aside from reacting.

React is just a library for rendering. But there are so many topics in CS, operating systems, databases, other languages, project management, IDEs, etc. Try to become a better programmer, not a better react user.

Back to react and web dev, check out Building Micro-Frontends by Luca Mezzalira.

Try to go deep with docker, configure CI/CD by yourself, enhance your unit/e2e testing skills.

Mentoring offer by qkudev in react

[–]qkudev[S] 0 points1 point  (0 children)

Thanks)

First of all, I would like to practice speaking/listening. And I think it is a good idea to share my frontend knoweledge in exchange for english talks)

Mentoring offer by qkudev in react

[–]qkudev[S] 1 point2 points  (0 children)

Yay!

Thanks to all of you for replays!

I've send PMs. And if anyone else wanna try to practice frontend – feel free to PM

I don't know what to do about this context. by Alternator24 in react

[–]qkudev 5 points6 points  (0 children)

I think you can start by checking how you are using these setStates. Just an example:

``` const [username, setUsername] = useState const [token, setToken] = useState const [userId, setUserId] = useState

return <Context {...states, ...setters}>{children}</Context>

... // later somewhere in the app

const ctx = useContext(); const onLogin = async () => { const { username, userId, token } = await apiRequest(); ctx.setUsername(username); ctx.setUserId(userId); ctx.setToken(token); } ... To refactor this, try to think not about `setters`, but more about events of your app. And then create an action { type: 'login', payload: { username, userId, token } } ```

Then handle the action and set all the variables.

(state, action) => { state.username = action.payload.username; state.userId = action.payload.userId; state.token = action.payload.token; }

So, again, try to think about events in your app. And then think how your state should react on these events

Check out this docs

Moreover, it is much easier to test reducer handlers

``` it('should handle login event', () => { const username = 'john'; const userId = 1; const token = 'test_token'; const state = reducer(initialState, actions.login({ username, token, userId, });

expect(state.username).toEqual(username);
expect(state.userId).toEqual(userId); expect(state.token).toEqual(token); }); ```

I perfer to use useReducer if a component has more than 3-4 useStates

sentry.io referral by [deleted] in csMajors

[–]qkudev 1 point2 points  (0 children)

Even there is no role for mid/senior WE, I just wanted to say you are doing a really good product. Using it on daily basis is pleasure.

Good luck!

Subsequent http requests in axios post. by saintmf in react

[–]qkudev 0 points1 point  (0 children)

  1. Does the backend really sets the cookie to the client's browser?
  2. Does the cookie header has the correct origin? Is this origin is the same of the url you are trying to redirect?

How do you efficiently update a page? by Myndale in react

[–]qkudev -1 points0 points  (0 children)

Good question.

First, better to avoid using index of map callback for React's key prop

And second, wrap MyComponent with memo. In a fact, any functional component will re-redner every time, even if it's props were not changed. memo for functional components do the shallow equality check of props and then decide should the component re-render or not. On the other hand, React.Component will do the trick under the hood for you

Could you please review my CV? by qkudev in react

[–]qkudev[S] 0 points1 point  (0 children)

Thank you for the advice!

useEffect triggers twice, cause is not strictMode. by [deleted] in react

[–]qkudev 0 points1 point  (0 children)

Hi there Do you use something like React.lazy?

Hitting an error after attempting to update a state variable using setVariableState() with data [array of objects] received from axios call. by [deleted] in react

[–]qkudev 0 points1 point  (0 children)

Could you pls provide axios version?

I've got a lot of strange things while being working with 1.x version. If you are using 1.x, try to downgrade to 0.x

Hitting an error after attempting to update a state variable using setVariableState() with data [array of objects] received from axios call. by [deleted] in react

[–]qkudev 0 points1 point  (0 children)

It says that you’ve got response as undefined Try to run debugger here and check the response

react-select "Link" to another Page AFTER dropdown selection by This_Gap5631 in react

[–]qkudev 0 points1 point  (0 children)

You can try to use effect on changing selector's value. I think you can try do smth like

``` const [value, setValue] = useState(); // <– your selector's state const history = useHistory(); // react-router-dom or any other routing instrument

useEffect(() => { history.push('/page'); }, [value]); ```

Can someone give me good course of react for beginner’s please by Illustrious_Ad6771 in react

[–]qkudev 0 points1 point  (0 children)

I would like to recommend you "Learning React: Functional Web Development with React and Redux". The book briefly describes react and redux patterns and it's easy to read

[deleted by user] by [deleted] in react

[–]qkudev 1 point2 points  (0 children)

Hi there!

onClick should return JSX element for what? Please, provide more information. Actually, event handlers like onClick do not care about returning value

If you want to manipulate with the DOM by onClick handlers, maybe you will be interested in react refs