Skip to content
Advertisement

Tag: reactjs

(REACT JS) put value on 1 array element from component

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

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

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

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

Advertisement