I’m trying to give one component the array value at a certain index and assign a value that i want from the child component. I want it like this because I’m trying to do a survey app and the number of question can be different. this is just a little test that concludes what I want. the base Component the
Tag: reactjs
Can’t persist checkstate in reactjs and nodejs
This would be my first time of doing this and I can’t seem to find a way around it. I would like to persist check box state in react.js and would like this to be done without my MongoDB database. Here are my codes so far: I am fetching list of subscribers from my MongoDB database like this: This displays
Can’t focus on object before it is hidden (react)
I have this input that when focused opens up a select. The behavior I want could be achieved with a simple select but I wish to further add functionalities that a simple select does not allow. Simply put when you have the ‘box’ focused, you can view the options, when you don’t you cannot. I tried to implement this logic
React – Error while rendering child component with prop passed from parent component
I have a problem while creating my react app. I’m fetching data from CoinGecko API to build a crypto tracking app, but when I pass the data prop from the parent App.js to the child Info.js. When I try to render the page it gives me Info.js:45 Uncaught TypeError: Cannot read properties of undefined (reading ‘large’) . I really don’t
How to create a button to enable/disable zoom and pan for leaflet in javascript react?
As the title says, I’m searching how to create a button to enable/disable zoom and pan for leaflet in javascript react. Actually creating a button is fine, but getting the effect I want on my map is not. I am working on a react project and trying to implement a leaflet map that swiches between an “edit” mode and a
Why export default doesn’t work in this simple code?
Why when I use export default on index.js module it says: export ‘appReducers’ (imported as ‘appReducers’) was not found in ‘./reducers/index’ (possible exports: default), but when I change it to module.exports the error go away, why is that? At redux.js in index.js in app.js Answer The problem is in redux.js. Instead of You need What you were doing before was
Controlled from in React
I’m new in react and I’m a bit confused about how React runs update on every new input’s keystroke, for exapmpe, this is the form and I want to update the state on every keystroke What I don’t understand here is the update cycle, my understanding is the following: As the input’s value is tied to react state, the initial
React conditional rendering based on other state doesn’t work
I’m new to react and I honestly can’t understand conditional rendering. I have one useState and one useReducer: Following tutorials, I made a calculator with currentOperand, previousOperand, Operation and every time the currentOperand is 10, I want trivia to be “something”. I honestly don’t understand, since I don’t get any errors. I tried this: and this but nothing appears. Not
Compare and update two arrays without losing mutated data
I have an array of objects contains data of persons then I add data to this array to each element where I end up with new key called money with value of 20 as the following and the array becomes like this Now, I have a new array with new data (new person) but missing the money I have added
Type json in React components
I have a dynamic json, for example: And I created interface for this: I have two components: But this return me error: Type “IResult” is not assignable to type ‘string’. in line: <SecondComponent result={result}> What I’m doing wrong? Answer When you pass arguments to a component, it is taken as props. By defining SecondComponent as function SecondComponent(result: IResult) {}, you