I am trying to create a Design System using ReactJS and TailwindCSS. I created a default Button component with basic styling as follow: I then use the Button in my page like: This is what is displayed: Some attributes are overridden like the background-color but some aren’t (the rest). The reason is the…
Tag: reactjs
Unexpected output using react-router-dom with React’s Context API
For a small project of mine, I’m trying to implement the most basic authentication as possible, using the React context API without Redux. I created a context, and wrapped my <App /> component in it like so; <AuthProvider></App></AuthProvider>. Because I want to keep the authenti…
TypeError: ‘addcart’ is not a function in reactjs?
I made a page that contains products and they should add to the cart. But after connecting the backend from asp.net core to the products page, add to cart button is not working on the Product.js page. context.js Products.js Also there is a problem in this details.js page backend data is showing on console.But…
How can I map multiple data objects inside my return function?
I have JSON object called finData which holds arrays of data. I would like to map through one array, for my case, finData[0], while also grabbing data from other arrays inside the JSON, ie. finData[1], finData[2], etc… Everything works fine and dandy mapping through one array. However, when I bring an o…
Remove an object with the same value of an array inside an array javascript
I have array like this: Then I filter the number to get a number that is less than or equal to 10 digits. Then returns an array with items that do not match a number. I then iterate through each of the above items, then push it into an empty array to get each individual item. And my final result
React setState does not update a state array value
I am trying to change the state in a class component by using setState. More specific I have a table, and I want to edit/update one of its elements. For this case, I am passing the indeces to the handleTableFieldOnChange function for the position of the value in the array. Since I know that I should not mutat…
Stale closures with react hooks and click events
I have created a codesandbox for easier debugging: https://codesandbox.io/s/hardcore-dirac-nh4iz?file=/src/App.tsx I have built a DataList component that I use like: All of the functionality is handled inside of a useListBox hook, which includes taking the onSelect prop from each child and binding that to a c…
How to display result of map in two different columns
I have a task, but i couldnt get the solution for it in reactjs. I would like to show the result in two columns like: So every next element should be added in the second column, but the first column should be limited to 2 rows. When i loop through the array the columns are getting divided into equal order,
How to use script tags in React?
I am pretty new to React and I wanted to try incorporating some pure Javascript in my React component. I have an html file of the script tags that I want to use which works, but obviously in React it is a little more complicated then just adding some script tags. From what I have been reading, it seems like
React Router Linking using
I am using React Router. I want when the user clicks on the button, it directs them to the page (endpoint) /form which has the UserForm component. Here is my code wrapping the button: Answer