I’m building a Node and React app, both using TypeScript. Its directories tree is as follows: My question: Since I’m using the same language for both stacks, and in the future the React Native will be added also using TypeScript, I wonder how I can create one group of classes to be used for all of them. Why I want
Tag: reactjs
How to render custom generated ruleset in styled-jsx
TL;DR How does one insert a variable that contains one or more CSS rules into styled-jsx (using styled-jsx-plugin-sass under the hood)? I have the following JSX style: And contained is a variable that I’m trying to insert into it the mentioned rule: Notes: breakAt is a function that generates a specific media query (breakpoint: string) => (content: string) => string
Recursive counting in arbitrary nested object
I’m attempting to do some data visualization and dealing with this dataset. Object with arbitrary nested objects. I’m trying to count how many times different values appear in a key. This is just a snippet of the dataset, in the original the owns nested objects go 7+ levels deep. Example dataset I’m working with: I’m thinking I’ll have to do
React JS app getting error – Error: Element type is invalid
I created an app using create react app. I added a functional component named Signup which is called from App.js. And I am getting an error on screen. It says I am not exporting component properly. I could not understand what is wrong. I am putting the three component files here. Here is my file structure Signup.js App.js index.js Folder
React Setstate callback called but render delayed
I just started to learn to react 2 days ago and I’m having a hard time with react’s setstate method, all I know is use revstate parameter if want to change state based on previous state, and callback parameter to be executed right after the state change (please correct me if this wrong), so I just change the array content
How to get Data info from OpenWeatherMap API ‘dt’
I am making a simple react app with OpenWeatherMap API. I need date info from that API to show which day is the current day. The API returns me a dt object I think this is related to date but I can’t use it. How can I convert it to a valid date string? I found a topic about this
Executing a loop in React class component
I’m building a pagination component and I’m struggling to execute a for loop so I can dynamically generate the pages. I initially had a function component, but I want to switch it to a class component so I can manage state in it. (I know, I can use hooks, but Im practicing class components at the moment). I initially added
change parent state from child
I want to change the parent state from the child but I can access the callback function just once Answer Try this:
TypeError: Cannot read property ‘length’ of undefined, API TMDB
I am using the TMDB API which allows me to display movies in a list. I have my Add.js component which allows me to make a query and search for the movies and add them to my list But I get this error: TypeError: Cannot read property ‘length’ of undefined Add.js Answer The problem is happening at this line of
How to change the child state component from parent in functional component
I have created a Count down timer component and I have a Button near this component and I want when users click on this button, resets the timer and for doing this I should change the child state I found the solution for changing parent state from the child but I don’t find the solution to this can it be