score:1
score:3
yes, it is allowed. recoil atom state can be an object. you have initialized the atom correctly, but when you set the atom you have to pass an object since the state is object.
initialize the currentuserstate
atom
export const currentuserstate = atom({
key: 'currentuserstate',
default: {name: '', email: '', userid: null}
});
and then set the atom state as follows
import {currentuserstate} from '../recoilstate/atoms';
const setuserstate = usesetrecoilstate(currentuserstate);
setuserstate({
name: 'john',
email: 'foo@bar.com',
userid: getrand()
});
Source: stackoverflow.com
Related Query
- Can the default value of a recoil atom be an object of objects?
- Can the default value of a Recoil atom be an object?
- How do I set the result of an API call as the default value for a Recoil atom?
- How can I set the default state of a checkbox based on value in firestore in react table
- React Recoil selector not triggering its get when the atom state updates to a previous value
- How can I set the value of a Form.Item without a form object in Ant.Design?
- How can I change the value of an object in an array in react redux when the action is called?
- Can not change the default value of <select> useing the react states
- I can print a state object array, but when I try to access a value from an object in the array, the whole object is undefined
- How can I change the default value when there is nothing in select?
- How can I access object value that is inside the object?
- How can I set a default image if the image link value is null?
- How can I update the value of an object while mapping through it's array?
- how can I set the reducer's return value to state object in component in react js
- How can i update a specific value of a recoil state object
- is it possible to give an empty object in react state for the init default value
- How can I prevent to add data if the object property value is different using react js
- Can a react/javascript object child have a value and children at the same time?
- How can I set an object to a constant and display the value in react?
- How can I fetch data from an array of objects, pass it through an API end point to .fetch() the needed object value using React?
- How can I get the object which has been changed and also the new changed value when Selecting options from the drop down
- how to remove default value in mui textfield so I can type new value without showing the default one?
- how can i set object list in default input value
- How can I make the default value of an input changeable in ReactJS?
- Can i set default Object value in select
- How can I change the value of an object in react based on form data input by the user?
- how can I change the value of an object in an array being mapped from state react
- How can I get the state value in the reducer of createSlice?
- What is the default value of React.PropTypes.func
- How to do POST in FORM Submit using reactjs and pass the object value into REST service?
More Query from same tag
- React-router: How to manually invoke Link?
- Using LocalStorage with React?
- Can't pass state with Link compoment. Why is state undefined?
- Apollo mutation not appearing in props
- On click on the `submit` button in the form system is not getting the form field values
- Asynchronous initialization of Redux state
- how to make fixed marker in center of google map in react?
- Object.keys() and find
- Expected Array but received array in Jest
- React redux - updating nested array in state
- Retrieve Custom Attribute from JavaScript (using Javascript Adapter) Keycloak
- Webpack error - can't resolve loader in 'tmp/build...'
- Can React.createRef() be created dynamically from an array of state objects?
- Memoize function argument in custom hook
- Setting Routes for Deployment
- Yup validation for multiple checkboxes
- How to manage the asynchrounous nature of useState hook when setting a value and using it directly after
- React - Django : TypeError: Cannot read property 'token' of undefined
- React JS how to update value in array
- Mocking a function jest but jest calling original function
- copy object using map in Reactjs
- Relay was unable to reconcile edges on a connection
- React - Can we calculate the time between onMouseEnter and onMouseLeave over a component?
- Module build failed: ReferenceError: [BABEL]
- React Ref: Ref function for an array of objects only logs 1st item
- Change Nextprops in componentWillReceiveProps
- How can I remove the grid line in the background of the line chart?
- "Expected 1 arguments, but got 2" when passing a useState function in TypeScript
- changing a text with my switch component toggle
- How to read object URI (JSON file) from JSON file