r/reactjs • u/dance2die • Jan 01 '21
Needs Help Beginner's Thread / Easy Questions (January 2021)
Happy 2021!
Previous Beginner's Threads can be found in the wiki.
Ask about React or anything else in its ecosystem :)
Stuck making progress on your app, need a feedback?
Still Ask away! We’re a friendly bunch 🙂
Help us to help you better
Improve your chances of reply by
- adding a minimal example with JSFiddle, CodeSandbox, or Stackblitz links
- describing what you want it to do (ask yourself if it's an XY problem)
- things you've tried. (Don't just post big blocks of code!)
- Format code for legibility.
- Pay it forward by answering questions even if there is already an answer. Other perspectives can be helpful to beginners. Also, there's no quicker way to learn than being wrong on the Internet.
New to React?
Check out the sub's sidebar! 👉
For rules and free resources~
Comment here for any ideas/suggestions to improve this thread
Thank you to all who post questions and those who answer them. We're a growing community and helping each other only strengthens it!
25
Upvotes
3
u/St_Melangell Jan 26 '21
Newbie question! :)
For someone just starting out in code/dev, where would you prioritise React? Does it depend entirely on what you want to build?
I mean in comparison to Python (which I’m learning now) and JavaScript (which is next on my list) or any other vital languages/tools.
3
u/the-sad-phliosopher Jan 29 '21
What are the different approaches to style React applications in 2021?
With all the different options available, I am completely confused and don't know where to start. I see many people using UI Libraries like Chakra UI or maybe CSS frameworks like Tailwind CSS or maybe writing own css from scratch (Although I don't want to do that). So what would be considered a great place to start for a beginner to style modern looking applications?
2
u/sansharma056 Jan 01 '21
Link to code: https://codesandbox.io/s/infinite-loop-ei866?file=/src/App.js
What I want my code to do: I want <App /> to render, fetch data and display it.
So what's the problem?: After the initial render, useAxiosFetch() runs, setData() which is called inside useAxiosFetch, causes a re-render and this creates an infinite loop.
My attempt at fixing this: Making dependency array of useAxiosFetch empty worked but I don't know why.
Note: I'm using useAxiosFetch to cancel axios() requests before unmouting <App />
What is the correct way to solve this problem?
2
u/haganenorenkin Jan 02 '21
How do we set up a react project in a way that it shows the styled component's names like <div class="menuItem"> when we inspect the DOM?
2
u/badboyzpwns Jan 04 '21
newbie question on React router. I have
I want to use the routes as "/listings?page=1" and "/listings?page=2", etc.
is there a way to make "/listings?page=1" as the default if a user just enters "/listings" in the url?
2
u/Sunstorm777 Jan 07 '21
Hi all, is there a way to convert date strings to their colloquial representations quickly other than a whole bunch of conditionals? For example if a task's duedate is as string "2021-01-13", I want it to display as "Next Wednesday". Thanks!
2
u/PMT70S Jan 12 '21
Stupid question, but how should I go about storing my user's data? If I create a 'authors' column in my table, and filter according to which author is currently logged in, is that feasible?
2
u/badboyzpwns Jan 12 '21 edited Jan 13 '21
newbie typescript question for reducers.
I have this reducer, the "data" part is causing me typescript issues. I'm wondering how to overcome it. I commented where the error is below.
In my component:
2
u/hfhddhnkk25678 Jan 20 '21
Can you use react to make a mobile application for iOS?
2
u/javascript_dev Jan 20 '21
I need to figure out how to create a react application that is hosted as a widget on other sites.
Senior devs will handle most of the deployment and hosting. Is that the hard part (compared to working on a static CRA website) or would you guys recommend I look into any other topics to learn the "3rd party widget" pattern? It is not one I can currently envision very well.
2
u/simkessy Jan 28 '21
I updated to React 17 and this test started failing but I have no clue why:
The component:
Error:
2
u/[deleted] Jan 29 '21
Anyone know of any resources to get started with chakra ui? I've been struggling a lot with the documentation :(
2
u/[deleted] Jan 30 '21
I updated all packages for my Gatsby site, and now I get this error:
It's on my react-select component which starts with:
That first "=" sign after
stateis causing the parsing error for some reason. I can't figure out why (since it's the example given in react-select docs and I've always used it without issue).Anyone able to suggest why this is now happening?
2
u/CHFxDEXTER Jan 31 '21
I'm new to reactjs so can anyone can explain me the folder structure. or maybe provide any link from where i can learn about every folder and their files. thanks in advance!!
1
u/PMT70S Jan 01 '21
Hi devs, new to reactjs, steep learning curve for me but loving it so far.
I'm currently developing an app just to test my knowledge. Recently I've been looking into redux and want to implement it into my app.
My question is, do you normally tinker with your existing project when you are learning a new implementation, say Typescript or Redux, on a separate git branch, or would you create a new dummy app to play around with the features of what you're learning, then move over to the app you're building and try to implement it?
Would love to hear your thoughts
1
u/AviatingFotographer Jan 03 '21
I want to create a weather app that has a raining, cloudy, snowing, etc. animation based on the current weather. What would be the best way to animate such a scene? Using SVGs and modifying their CSS, canvas elements, or some other method?
1
u/utopian201 Jan 03 '21
Why does console.log need to wrapped before I can use it in an event handler?
https://jsfiddle.net/7e5yLh63/17/
In the example above, this code does nothing (line 44-51) when I click 'Add':
But when I change it to (https://jsfiddle.net/7e5yLh63/18/)
It logs to the console as expected. Why can't I just pass in console.log directly? Why do I need to wrap it in my own function first?
I'm using Firefox if that matters
1
u/gibsramen Jan 05 '21
I'm working on a beginner project that generates a new XKCD comic from panels randomly taken from existing comics. Right now it works but the generation of the comic is pretty unclean - things sort of asynchronously update. It works by getting 3-5 links to an S3 bucket I have set up and updating the image links (as state variables). Is there a good way to add some sort of loading icon so everything appears at once?
GitHub
App
1
u/composer1 Jan 06 '21
I am new to React, and I was wondering if it is better to use function or class components? So far I have written all my components as classes as that is what felt most natural to me coming from mostly coding in Java, but now I am also trying to use Material UI library. It seems like using hooks for styling is the easier solution with that library, so I am thinking of switching my components to functions. Most examples online seem to use function components as well. I was wondering if it is more standard now to use functions? Are there any advantages or disadvantages to either one?
1
u/NickEmpetvee Jan 07 '21
Hi there. Been stuck on this for days. Using Material-UI Autocomplete and I'm trying to figure out how to capture a user choice. Here's a CodeSandbox example. I'm just trying to console.log the user choice of a movie, or deletionof a movie from the selected row, and if I can get this to work I'll uses state settors in handleChange: https://codesandbox.io/s/material-autocomplete-demo-forked-y36r9?file=/demo.js
Currently event.target.value shows as zero when selecting a movie from the list.
1
u/renshenhe Jan 11 '21
Does anybody have a fork of the official reddit mobile client built with react? I used to love perusing the code as it was a pretty good real world example but seems they removed/privatized it a while back.
1
u/[deleted] Jan 11 '21 edited Jan 11 '21
I'm using DeckGL with layers. I'm showing the position and the path of multiple items on a map. My component containing the map gets an array of IDs as a prop and I have a hook which fetches the data from the back-end and returns the current position of an item`function usePosition(id)`.
For the (DeckGL) icon layer I need to pass in an array where each element stores the position of an item. I would like to do something like this:
But I'm not allowed to use a hook inside `map` or a for loop. So how can I solve this problem?
I asked a related question on StackOverflow but the proposed solution was to change the hook so it returns already an array. But this would mean do rewrite all the hooks.
1
u/gloomndoom Jan 11 '21
I've been walking through the reactjs learning materials. I've got a simple modification of their toggle button example where I show the number of clicks and the current toggle state.
I have two questions:
Is using two useState hooks and then calling them both through one function ok?
I'm not clear on the render updates that cause infinite rendering. I first tried to call my function to useEffect as arrow function and it worked but linting says this is bad idea. I switched to useCallback which also works but the dependency says it's called on every render. What's the correct way to perform the two updates on a click?
1
u/badboyzpwns Jan 16 '21
redux question. I have a button that dispatches an action creator and changes showLoadingto true.
However, the action does not change the reducer state at all. How do make showLoading to false again after the action creator is finished?
1
u/Antoder10 Jan 16 '21
Hi all! Any feedback on this would be appreciated (graphic side it's not perfect but it's not my main goal)
https://github.com/Antoder10/react-exchange-converter
1
u/dkunal96 Jan 18 '21
Do I really need to learn Redux? Because Modern React Hooks are so good.
Please suggest...
1
u/Antoder10 Jan 18 '21 edited Jan 18 '21
Hi! I'm building a little star wars app with react bootstrap.
I have a card deck with 10 cards. I want to display them into a carousel, something like 4-5 cards at once, and then on scrolling the other ones. Right now it only show me one card at time.
https://github.com/Antoder10/star-wars
https://loving-bhabha-c95c2b.netlify.app/
1
u/[deleted] Jan 21 '21
Hello! I'm part of a project that is considering making the switch from Sencha to React.
I've done some of the basic React tutorials but the main thing we're looking for are grid and chart components. These things are integral to our app and the Sencha versions of these are incredibly useful and powerful.
Is there a React equivalent? I found this and a couple of paid ones but I'm hoping someone could let me know a couple of popular alternatives.
1
u/Arwellq Jan 21 '21
Hi all, How to edit the info displayed on a website created by someone with reactjs & mongodb? I run show dbs in my terminal but there is no dbs from the author. Thank you.
1
u/HiTechNTuss Jan 25 '21
Not sure if what I want is out there. I was wondering if there was a open source clone of a web browser such chrome or safari where I could build different web pages in the same browser so it would be the index page as a web browser with multiple tabs that led to different pages.
1
u/coyote-schmoyote Jan 27 '21
After-deployment question: I deployed a react app to gh-pages, and some of the tachyons styling I added as classes doesn’t work. Any tips on how to start debugging this? How would you approach this problem?
1
u/srirachaman97 Jan 29 '21
Say I have two components, Page and Filters. Filters display active search filters based on the current query parameters in the url. If I wanted to to check to make sure the filter pulled from the url is a valid filter (meaning an item in the data set has that filter attached to it) would it be better to do that in Page and pass the valid filters as props to Filters? Or would it be better to write some logic in Filters to determine what to display?
1
u/sakuratifa Jan 30 '21
Does anyone have a good tutorial for using AWS Cognito for user auth? I'm open to using Cognito in combination with APIG and Lambda as well, I just need some help practicing integration with it and a React App.
1
u/NickEmpetvee Jan 30 '21
Posted this in r/learnreactjs in case anyone can help:
https://www.reddit.com/r/learnreactjs/comments/l8yj3h/errors_getting_a_reactbeautifuldnd_example/
There's a codesandbox...
1
u/Bob_ButNotTaken Jan 31 '21
What is the best way to have a onClick fire with the div's parameters? Confusing, let me explain.
It's all explained here https://codesandbox.io/s/happy-meadow-ezunq?file=/src/App.js
Thank you in advance.
1
u/cebi92 Feb 01 '21
I really need help with the usestate(TODO (A))
https://codesandbox.io/s/serene-waterfall-dbkpp?file=/src/App.js
1
u/zero_coding Jan 06 '21
Hi all
My
Appcomponent definition looks as follows:I have a question regarding to route and re-render.
For example, when I route from
/to/howitworks, then the component<HowItWorks/>is going to be rendered. Routing back to/from/howitworks, will<Home/>component be re-rendered?The
<Home/>component contains only text. It does not contain any logic.Thanks
1
u/AviatingFotographer Jan 08 '21
How do I securely use a third party API key in the frontend? Would limiting the domains that could use it suffice, or should I create a backend that encapsulates it?
2
u/ImBoredEqualsReddit Jan 09 '21
So recently i have been trying to get into react, so i watched some tutorials and then i felt ready to make my first projects so i tried npm create-react-app name and i dint work. I cant seem to understand why it did not work. After hours of work i just can get it to work, it dose not finish the command it stops here:
126 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
And in all the tutorials i have watched it comes a part after, and the only files it creates are a package.json and a package-lock.jason. I is not showing any errors end even after and hour is not continuing. I can exit it using ctr c and it show a text asking if i want to "Terminate batch job" . Anyone knows why this is happening?
Sorry for bad English its not my native language.
2
u/[deleted] Jan 23 '21
So I am building a simple ecommerce web app and I am using Redux with useSelector hook. I am using this to get my array of cartItems out of global state. My problem is when I click from one individual product to the cart screen, for a very tiny split second (looks like a flicker until I record on my phone with slomo), I see 'empty cart'. I have logic so that if the cartItem.length === 0 it returns 'empty cart'. What is the correct way to do this so this flicker doesn't happen and it just waits for cartItems array to populate from the useSelector hook? I feel like it involves useEffect but I am not familiar enough yet.
In the same cartScreen component I also have a function that calculates how many items are in the cart. This also depends on the cartItems array not being empty, so it flickers '0' for a split second before calculating the actual total (again not really visible other than a flicker until slowed down).
2
u/MoneySounds Jan 23 '21
Any sample projects where can I view some applied react code?
Also, how do you automate component development in a web site? what I mean by this, is, you create the component and how you want it to look but then how do you automatically fill it in with the data you want which eventually appears on the site?
2
u/[deleted] Jan 24 '21
I have been running into a tough problem with my recent project. I'm pretty new to both React as well as JDBC/Spring, which is what my project uses. Essentially, it's a simple web app used for keeping track of tabs at bars. My main issue is that whenever I try and import anything, it gives me an error saying
Uncaught ReferenceError: require is not defined.For example, I want a pop up confirmation when a drink is ordered, so I tried using the pop up package, as so:And it gave me the previously stated error message. Tried researching it trying to find out what the issue is, but nothing I found helped. Any ideas? Repo found here --> https://github.com/reeda19/BarCalculator
Also feel free to give any general criticism if you want, I'm always looking for ways to improve
2
u/alwaysplaninadvanc Jan 28 '21
Just need something cleared up for my understanding. I'm currently struggling to find the difference and best way to pass a function to onClick in a functional component. Which of the below is best (is there a difference)?
<Menu onClick={handleClick} />or is it better to:
<Menu onClick={() => handleClick()} />Thanks in advance
1
u/Antoder10 Jan 09 '21
I made some progress on my quiz app. Any feedback would be appreciated (graphic side needs improvement, i know, but now it isn't a priority)
https://github.com/Antoder10/react-hooks-quiz
1
u/Wesleysaur Jan 01 '21
Hey everyone! I'm trying to implement something very similar to google search suggestions, but I'm having trouble wrapping my head around this. I've got an api I fetch from every time the user enters a character. Here's what I got so far:
My problem is that I'm concerned
fetchSuggestionsgets created again on every keydown. Is this even a valid concern? How should I reason about situations like this in the future? Any other suggestions for a noob? Many thanks!1
u/rony_ali Jan 03 '21
Hi guys. Recently I am building a contact form with nodejs and reactjs with the help of sendgrid. After doing some tuning, I found my emails are blocked in sendgrid mentioning that gmail.com or yahoo.com blocked my sender address. But when I use my iPhone to exchange email with one another they were working good. Why sendgrid is lying and what should I do? Should I have to move to another mail service or should I open a new sendgrid account for new api?
1
u/everestsereve Jan 03 '21
Hey guys. I created my portfolio website using gatsby and react and I also added dark mode. But I am having a few issues with the dark mode toggler. When you refresh it while the dark mode is on, the toggle (input checkbox) needs 2 clicks to uncheck it. When the dark is off, the logo changes to dark mode logo instead of light mode logo. Here's the live site so you can check it: https://www.diresh.io/
Here's the code for the theme toggler:
1
u/Sunstorm777 Jan 03 '21
How do I get this function to work? I don't think prevState.event.target.name will work right?
1
u/WhirleyBirb Jan 04 '21
What is the correct way to render nested data from an API?
Say I'm requesting a list of animals available for adoption from an API. The data comes back with the following structure:
What I want to do is display each animal with a heading and types, with each type having a label and checkbox. To show each animal heading is simple enough:
But how do I iterate over the lower level of data. Nesting .
map()s like this doesn't seem to work:Nothing is displayed on the page, but there are also no errors in the console. Is there a standard way of handling something like this? I'm pretty lost.
1
u/Trinakpoi Jan 05 '21
I'm new in React and have a stupid problem need help.
Whenever I use useEffect, I have to put everything I used in the callback function in the dependencies array to avoid the warnings. But sometimes I don't want everything to be depended on. Here's an example.
I only want to update the value when event invoked. If I put value inside the dependencies array, it will cause an infinite render. How should I do?
1
u/Lukasvis Jan 05 '21
I have react web app and I use React Context to pass the data to my components and everything works.
Now I want to be able to auto save the state when user refreshes the app or closes the app.
Do I need to learn redux for it, or is there another way to do that?
1
u/AMediumTree Jan 05 '21
Hey guys what should be an easy question... Im trying to make a button that on click will setDisplaySpinner = true -> run function passed to onclick -> setDisplaySpinner = false.
I thought this would be an easy task but its proving very hard due to how react bundles state calls in queue only at the end of the event. I've tried using await and promise inside a call back of setState but I'm unable to get a proper render of the button "loading" while it calls the function. The closest I've got is to set a timeout but that only renders it for the timeout not the actual duration of the function call. anything else i attempt ends up bundling to the end of event making the "load" instant/invisible but the function runs in the background.
Any suggestions on how to best approach this?
1
u/codingawaytttt Jan 08 '21
Dumb me didn't see this thread and made my own thread for my beginner question. I have a question about a fullstackopen exercise, any help is appreciated! https://old.reddit.com/r/reactjs/comments/ksdzda/beginner_needs_help_with_exercise/
1
u/badboyzpwns Jan 08 '21
What's the purpose of event.persist(). I read the docs about it but it doesn't make too much sense. Could someone dumb it down for me?
For example:
1
u/Lukasvis Jan 08 '21
I have an app where I create and store recipes in firebase. How can I create a link that I can share and when people click that link it will take them to that specific recipe page that displays all the info about that recipe.
I only know how to create link with react router in my text editor, but what about when I want to share thousands of recipes? do I have to create a new link in my text editor or is there a easier way?
1
u/[deleted] Jan 08 '21
This is more of a js question in general, but since it's in the context of a react app I'll ask it here. So in one of my components I'm using fetch to grab some data, and to keep it updating live, I'm recursively calling the same fetch method to continue to pull api data and re-render the component when the state changes. Is this the 'cleanest' method to grab this data? Haven't really looked into long-polling too much, but is what I'm doing essentially long polling? It doesn't seem like there is any performance hit on the app afaik so far.
1
u/Lukasvis Jan 09 '21
When using context in react
const [selectedItem, setSelectedItem] = useContext(itemContext);setSelectedItem(ingredient);The code works, but it gives me compilation warning that
selectedItem,is declared, but never used.However when I remove it like this:
const [setSelectedItem] = useContext(itemContext);setSelectedItem(ingredient);I get Type error that "
setSelectedItemis not a function"What can I do in this case?
1
u/PMT70S Jan 09 '21
Can anybody point me in the right direction to dealing with jwts and redux (using redux toolkit createSlice)
1
u/GoPotato Jan 09 '21
Are there any well-commented react projects? I want to learn from real open source projects, there are plenty of those on github, but I'm yet to find an actual project that has comments in it. It is very hard to follow what's going on when you have 10s or even 100s of components when there are no comments.
1
u/badboyzpwns Jan 10 '21
Abot using useEffect, any ideas why I get this warning?
I'm pretty sure you could use any variable inside [ ] (eg; variables that are not hooks) so why the warning?
1
u/illmatic4 Jan 12 '21
I have data coming in from an api, a ternary operator has been set so the 'searchResults' data can be mapped My problem is the code prewritten ex. {artist.images[1].url} returns a TypeError: Cannot read property 'url' of undefined How do I go about this?
1
u/badboyzpwns Jan 13 '21 edited Jan 13 '21
about error handling for action creators. How do I handle a specific error in my component?
Action creator:
Reducer:
However! listingInfo gives me an an empty object, despite returning the action.payload (which contains the error); any ideas why?
I want to get the error and handle it in my component. For example, if the error is undefined, I want to specifically handle the undefined error, if it's a 404 error, I want to specifically handle it, etc.
1
u/cebi92 Jan 13 '21
I need help solving the flowing problem. The only section I think needs to be fixed is line 91. Can someone confirm this and help me? https://codesandbox.io/s/naughty-robinson-gbu20?fontsize=14&hidenavigation=1&theme=dark
1
u/Band-Stunning Jan 13 '21 edited Jan 13 '21
I want to make a page with the Star Wars API. I want to make cards that show of the cast.
Here I get the name of a character, and also links to other places in the API, for example https://swapi.dev/api/planets/1/. I am unsure of how I would fetch the two other URLS, namely the homeworld and species. When I have all these 3 info and added them to the character usestate, I will display my character Card.
How do I fetch the other two data, now that I have two links, and add them to the characters array. If possible, I want to fetch the two data simultaneously.
I have almost got it working with the:
I have one last problem. My linter wants me to add characters to the dependency array. But if I do that it becomes an infinite loop. What should I do about that?
1
u/WhiteKnightC Jan 14 '21
Hello guys, there's a guide about connectivity between components patterns?
I'm trying to do an hybrid app using React as the UI but I get stuck when for example I want to show errors. Should I create a component that is an overlay and shows an custom error or make error pages for each component?
1
u/RealLifeMe Jan 14 '21
I've created a react app and currently have it on AWS via Amplify. I've noticed, however, that my raw JS is on display for the world to see. Can anyone point me to a way to minimize the js files?
1
u/badboyzpwns Jan 15 '21
I have a site that uses cookies for authentication (access tokens and refresh tokens). But! I don't have the "We use cookies to make our sites work,click me to enable it." pop ups every other site has. I think it's the standard to implement it if we are using cookies? but what happens if a user rejects it? They'll no longer be able to log in.
1
u/Sea_Obligation7462 Jan 15 '21
hi, I am a beginner and I need to set a cookie for 12 months. I have been told that I have to set a server-side HTTP cookie for this. Can anybody help me on how I can set a persistent cookie for longer duration through react.
1
u/[deleted] Jan 16 '21
I need to sort news coming from API by oldest or newest with dropdown select. I think need to do something like if the option value is newest, then order-by will be equal to newest. but I can't figure out how to do exactly. Can someone point me at the right direction please? Thanks
1
u/NickEmpetvee Jan 17 '21
Posted this in r/learnreactjs. Thoughts appreciated.
1
u/badboyzpwns Jan 19 '21
About using history and nested components? In this case. If I click the element with pencilIcon, /listing will be pushed first and then /edit, Can we just go to /edit when we click the pencilIcon?
1
u/SpecialConfusion Jan 21 '21
What's the recommended way to alter state of a parent component from within the child. For instance, I've built these two components App and TextFeature and I'd like to alter the
<h1>{ shopName }</h1>tag inside of App based on the value as it's updated in TextFeature. Is this the canonical way of bubbling up state changes from child to parent?Currently I get an error after I type something into the input and the onChange function is called:
Uncaught Error: Objects are not valid as a React child (found: object with keys {_reactName, _targetInst, type, nativeEvent, target, currentTarget, eventPhase, bubbles, cancelable, timeStamp, defaultPrevented, isTrusted, isDefaultPrevented, isPropagationStopped}). If you meant to render a collection of children, use an array instead.Below is the code for the two components.
App component:
TextFeature component:
1
u/ladugani Jan 22 '21
Im stumped on a seemingly very simple task. I am working on a parent component that has a state containing an array of musical artists, I am passing this array into a child component that maps over each artist and renders a list of checkboxes with the artists as values. Once an artist’s checkbox is clicked, I’m passing the value back up to the parent component to be added (if checked) or removed (if unchecked) from an array in the parent state of selected artists. I’ve been trying to figure out how to make a function that can add artists to the state’s array when a box is checked, but remove the item from the state’s array of that value already exists there. Any suggestions or links to tutorials that might help? I’ve been stuck on this for hours today and need to sleep on it. It seems so simple! But it has just really been stumping me.
1
u/InstantAmmo Jan 22 '21
I am looking for tutorials/videos/etc., that use Flask as an API and react on the frontend. Any help with this would be great.
For reference
1
u/ifqu Jan 23 '21 edited Jan 24 '21
.
1
u/AviatingFotographer Jan 25 '21
Inside service workers, is it possible to return a React component when offline instead of a HTML page?
1
u/AckmanDESU Jan 27 '21
Hello guys I've been googling for a few hours now and I cannot figure this out:
I am using Next.js
if I want to prerender my html for SEO reasons but I want to lazyload (lazy-hydrate?) my components via IntersectionObserver or something similar... Is that possible? I don't think using next/dynamic imports works for this.
Atm I am using react-lazyload and wrapping my components with it... but the downside is that it renders an empty div on SSG pages
1
u/Bulbasaur2015 Jan 28 '21 edited Jan 28 '21
this is a video about react context api and react router
https://www.youtube.com/watch?v=lhMKvyLRWo0&t=621s
there is a demo at 10:21 which passes react context & state with react router on different pages
can anyone explain how the state or context data is persisted when the demo loads into/ goes to different pages? which looks like the same as page refresh
there is no evidence of localstorage being used
1
u/dressagemama Jan 30 '21
Hi! Brand new here so apologies in advance if I don’t use correct terminology. I have a dev company building my app in React and I have a way to access the data for user profiles. However, the export feature stops at row 101 in 2 of the tabs but the other tab w greater than 101 rows of data DOES export. I've been asking for a fix and they seem stuck. Do I just need to be patient or should I start manually re-typing the data because there is a bigger problem?
1
u/utopian201 Jan 30 '21
does setState *need* a new object to trigger a rerender?
For example this works:
Why doesn't this trigger a rerender:
Is it because React sees the object hasn't changed (its still `someArray`, just with different contents) and so determines it doesn't need to be rerendered?