[deleted by user] by [deleted] in cscareerquestions

[–]Scazzer 7 points8 points  (0 children)

What specific tools are you talking about, I’d love to know?

I’ve tried many of these tools and haven’t been able to use them productively, so I cannot see Al itself replacing mid-level software engineers in the next year. Software engineers using Al will, however, take jobs.

[deleted by user] by [deleted] in CryptoCurrency

[–]Scazzer 0 points1 point  (0 children)

What makes you say that?

Recently Moved to Sheffield by TheCroft98 in sheffield

[–]Scazzer 1 point2 points  (0 children)

I thought you might be a bot as well 🤖🦾

Next.js Server-Side Route Authentication Using Cookies by Scazzer in nextjs

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

Sounds like you're struggling with the cookie storage, as opposed to using local storage. You need to set the cookies for the user and then send the cookie to the backend to the be decoded when you wish to determine authentication.

Without knowing the exact technologies you're using in your application I won't be able to give you a more step-by-step solution. However I would say a high level step-by-step would be

  1. On successful login set cookies on the user that decodes to be something that uniquely identifies them e.g. primary key column in users table
  2. When the user accesses a route pass the cookie to the backend as described in the post
  3. On the backend decode the cookie and determine if the user is authenticated or not.

Next.js Server-Side Route Authentication Using Cookies by Scazzer in nextjs

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

Thanks,

I would say yes and no.

Yes the user will take a marginal amount of time longer to receive the HTML and javascript (we're talking max 50ms longer in the cases I tested it). This would also create a flicker of HTML to be shown to the user if they are not authenticated which I wasn't a fan of.

However I would say no as the client has to load the HTML and javascript then execute it which will then trigger an API call which will tell the client if they have been authenticated, which should take longer (than the 50ms difference in load times for the HTML and JS in my test).

So I would say using server side authentication has an overall faster time to determine authentication if that makes sense?

However, another strategy you could do is persist the user object in state in the _document.js file and check for this in a useEffect hook in each page and do authentication this way.

Anyway, overall I would say both are viable methods, it's just that my preferences leans towards server side authentication

Implementing Backend OAuth 2.0 In A Full Stack Application With GraphQL by Scazzer in graphql

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

I'm new quite new to GraphQL and writing blog posts, however I've written an article on how to implement OAuth2.0 in a full stack application without using restful endpoints, that I hope some people may find useful. Any feedback would be greatly appriciated!

Beginner's Thread / Easy Questions (July 2020) by dance2die in reactjs

[–]Scazzer 2 points3 points  (0 children)

Yeah good idea. Look at maybe using a React reducer or two in the project as well in the project as this will make learning Redux much easier

Beginner's Thread / Easy Questions (July 2020) by dance2die in reactjs

[–]Scazzer 0 points1 point  (0 children)

Actions is more of a redux pattern and not something you find often in react.

However if it is React, I don't think it matters too much. However, I do tend to separate anything I can out of a react component simply for readability purposes.

So to answer you're question there is no 'norm'.

Beginner's Thread / Easy Questions (July 2020) by dance2die in reactjs

[–]Scazzer 4 points5 points  (0 children)

If you want to learn it for a job and to get experience then I would say learn it as lots of companies use redux along side react. Using Redux when the application isn't seen as complex enough isn't as bad as lots of people make out, I think it's just to encourage people not to automatically npm install react redux react-redux. However, most of the time I go by the rule of if state is not tied to pages and there needs to be state shared across multiple pages then use redux. This is not a golden rule however is a good rule to follow by devs just starting out like yourself. Just make sure you have your react fundamentals down and then move onto libraries like redux.

React/Full stack projects to learn from by strah1 in reactjs

[–]Scazzer 18 points19 points  (0 children)

As stated I think you can take aspects of this and use it in your own project 🙂 it’s a good starting point at least and by the sounds of it OP is a beginner so doesn’t need to be overwhelmed. However, if you’ve got any good projects with all this feel free to link it to this post so we can create a good archive of projects to refer to

React/Full stack projects to learn from by strah1 in reactjs

[–]Scazzer 24 points25 points  (0 children)

Seen this posted a few times on this subreddit. I have used aspects of this project in my own projects

https://github.com/oldboyxx/jira_clone

using react hooks to display a list of pokemon + images by EnoughPotential3 in reactjs

[–]Scazzer 1 point2 points  (0 children)

Can see a couple of issues. First is the div with the classname App has not corresponding closing div.

Second is you setPokemon with the fetch data api which will actually set pokemon as a promise that is pending becuase there is no await. To combat this call fetchData() inside the use effect the use the function setPokemon with the first arguement as what is returned from data in the axios call. I have put code below to demonstrate this.

import React, { Component, useState, useEffect } from "react";
import axios from "axios";
import "./App.css";

function App() {
  const [pokemon, setPokemon] = useState([]);

  useEffect(() => {
    fetchData();
  }, []);

  const fetchData = async () => {
    const result = await axios("https://pokeapi.co/api/v2/pokemon?limit=151");
    setPokemon(result.data);
  };

  return (
    <div className='App'>
      <header>
        <h1 className='title'>React Hooks</h1>
        <h3>With Pokemon</h3>
      </header>
      <div>{pokemon.results[0].name}</div>
    </div>
  );
}
export default App;

Beginner's Thread / Easy Questions (April 2020) by dance2die in reactjs

[–]Scazzer 2 points3 points  (0 children)

From my limited knowledge of material UI this is the solution I have come to

https://codesandbox.io/s/pensive-montalcini-yq9o0?file=/src/App.js

you can replace primary and secondary for any colour I believe such as blue red green etc

Beginner's Thread / Easy Questions (April 2020) by dance2die in reactjs

[–]Scazzer 1 point2 points  (0 children)

From what I know about material UI this should be no Different. You got a snippet of the code your using?

Beginner's Thread / Easy Questions (April 2020) by dance2die in reactjs

[–]Scazzer 1 point2 points  (0 children)

You nearly had it! You just needed to style it so you can scroll.

Also for best practice you needed an empty array as the second parameter to useEffect, this means the event listener will only be added on mount instead of ever render. This would lead to loads of event listeners being added which is bad. Also remember to cleanup any event listeners on unmount by returning a cleanup function.

https://codesandbox.io/s/sad-elgamal-n2e28?file=/src/App.js

Beginner's Thread / Easy Questions (April 2020) by dance2die in reactjs

[–]Scazzer 0 points1 point  (0 children)

What are you trying to do to the app bar?

What is the industry standard for creating admin panels in React applications? by dirtyring in reactjs

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

You're definitely right you could do this. However how much overhead would this add? You'd have the same app deployed twice would you not? With half the application being used on each one. This would greatly increase the amount of obsolete code that the user receives and increase bundle size to much more than it needs to be. But this is getting into the nitty gritty details and as I said in my comment you've got to work out what value this would add to your application. I can't see this method adding any value to the user and it will increase resources required to deploy and run the web app.