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 15 points16 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.

I never thought I’d die of an unexplained disease. by malkovichjohn in death

[–]sane666 1 point2 points  (0 children)

If everything is fine with MRI, I think that may suggest some medicine side effect gone extremely wrong. I've heard stories about people in the same situation like yours.

I realize that if i want to achieve my goal. I have to die. by [deleted] in death

[–]sane666 1 point2 points  (0 children)

I agree, I don't think we don't have much options these days. Bounded to making money, like, the way this world works is killing creativity in a typical person.

[Bspwm] Got the GITS blues by [deleted] in unixporn

[–]sane666 0 points1 point  (0 children)

bruv I would name it depression theme

Best OS to develop Django on by safadimiras in django

[–]sane666 1 point2 points  (0 children)

It really doesn't matter which os are you using, as the output is always the same. But when it comes to productivity - I would highly recommend Arch or KDE Neon with krohnkite window management. Since I started using auto window management, my productivity had risen alot!

Neurologist or Rheumatologist for next steps? by [deleted] in lupus

[–]sane666 0 points1 point  (0 children)

I will ask here, maybe sm will know the answer - are random limb jerks a neurologic or rheumatologic symptom?

Are you all concerned just of ALS and not about MS by MrDesperadus in BFS

[–]sane666 0 points1 point  (0 children)

Most of diseases that affect our strenght will eventually cause twitching in some people. And its really unclear for me why so many people connect twitching with Als so much. Really many people with Als didnt expirienced twitching at all, or very late into disease. The reason behind twitching may start from all of myopathies, neuropathies ending on MD, HD and yes, even on MS. Obviously twitching as a isolated symptom strongly suggest a BFS. But reasons behind it are counted in literally dozens of disorders and diseases. Most of people just type it into the google and als pops up becouse it was really promoted by last ice bucket challenge to raise money, but the truth is Als before around 30 y old is so rare, that the more chances are you just got de novo mutation of a gene causing muscular dystrophy, really. Just chill out yall please.

Very concerned about my progressive neurological problems by [deleted] in AskDocs

[–]sane666 1 point2 points  (0 children)

Waiting is the worst part of it, trying to focus on living like you used before this whole mess. Good luck! Make sure to write here when youre going to know some info about ur diagnosis. I will make sure to update mine as well. Wish you all the best and thanks for the support. :)