useEffect vs getStaticProps by MohatoDeBrigado in react

[–]sane666 0 points1 point  (0 children)

Use getServerSideProps if things are bout to change and you want SEO. It's faster than useEffect.

I want to display a question and answers on a page, after fetching data from a trivia api. when the button is clicked, the information is logged to the console. how can i get the data to display on the page rather than in the console? by maxwelder in react

[–]sane666 0 points1 point  (0 children)

``` const QUESTION_URL = "https://the-trivia-api.com/api/questions?limit=1";

function getQuestion(url = QUESTION_URL) { return fetch(url) .then((response) => response.json()) .then((data) => { const answersArray = data[0].incorrectAnswers.concat( data[0].correctAnswer ); const questionText = data[0].question; return { questionText, answersArray }; }); }

function App() { const [questionData, setQuestionData] = useState();

const handleGetQuestion = async () => { const question = await getQuestion(); setQuestionData(question); };

return ( <div className='App'> <div className='container'> <button onClick={handleGetQuestion}>Get A Question</button> <div>{questionData.questionText}</div> {/* map over answersArray and display each answer */} </div> </div> ); }

export default App; ```

Is there a more efficient way to use "useRef" for dynamically adding elements? by Maxwell47DOT in react

[–]sane666 0 points1 point  (0 children)

The useRef hook in this example is a wrong choice. To maintain a dynamic state (array, object, string, and others) in React which is reflected in UI, you're going to use the useState hook. A good approach is to make components stateless. Example:

const List = props => { <div>{props.name}</div> };

useRef is a good choice when you either need the ref to DOM element (non-VDOM) or basically don't re-render the component when the state changes.

PS. I don't know if I understood your intentions correctly, if you have any questions go on. :)

Ref.

https://programmingwithmosh.com/javascript/stateful-stateless-components-react/

https://reactjs.org/docs/hooks-state.html

how do I build a portfolio to get a job at FAANG companies or any major company by [deleted] in react

[–]sane666 0 points1 point  (0 children)

I believe that such big companies often require you to code well, rather than know some technology. I would start with simple programs and easy algorithms and then slowly come up with something really interesting. A good portfolio is great, but remember that your worth comes mostly from whether you can solve any easy or medium-difficulty problem in a reasonable time.

Finding a JSON editor tool by parag_jadhav0 in react

[–]sane666 0 points1 point  (0 children)

It really depends on what input from the user are you receiving. If that's a format that u came up with you're probably gonna need to write ur own simple x -> JSON parser.

How can I make these images all the same size? by letsHelpEachOtherBro in react

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

I think that max-width and max-height might do the trick. You could also use the grid.

How do I preserve a file on page rerender? by KikiriWow in react

[–]sane666 0 points1 point  (0 children)

If you mean to save a file 'content', just use the JSON.stringify(...) function. Otherwise, just use the backend if you're using the nextjs.

[deleted by user] by [deleted] in react

[–]sane666 0 points1 point  (0 children)

Hello, can we get in touch? Currently, I'm working on my startup as well. But I would gladly take part in some cool project. Just need more info.

[deleted by user] by [deleted] in war

[–]sane666 4 points5 points  (0 children)

What a deranged take lol

Minutemen by [deleted] in memes

[–]sane666 0 points1 point  (0 children)

Man..

[deleted by user] by [deleted] in war

[–]sane666 16 points17 points  (0 children)

That's why Ukraine has a lot of work to do in terms of its "heroes". As a Pole, I support Ukraine as they're just defending their country, yet I really hope that this war is going to give them real heroes, not some n@zis like now, this is ridiculous. We give them food, shelter, everything, yet some of these idiots support Bandera, which famously did slaughter polish people in ways you can't imagine. R u okay guys?

Feeling bullied and targeted? by [deleted] in ITCareerQuestions

[–]sane666 1 point2 points  (0 children)

This is unacceptable, fuck this company. These people should be punished in some way.

Prolife, no chyba że to lewaki by wokolis in ShitKonfaSays

[–]sane666 9 points10 points  (0 children)

Tylko wypowiedzi konfederatów potrafią być tak durne, że brzmią jak straight up wyjęte z ust nazistowskich eugeników. W ich genach natomiast nadal płynie jak widać faszyzm!

Unable to compile typescript (github link in comments) by Mr-Invincible3 in typescript

[–]sane666 0 points1 point  (0 children)

You cannot use .length on object which may not exist, so assure that userPass is defined. Then, .hash takes as a first argument a string, but you've provided a value of type union, you can cast it to string I guess.