Comments (16)
All of the form elements within formsy-react-components
are controlled components, maybe you are switching them to an uncontrolled components by using undefined
or null
as values?
See:
- http://facebook.github.io/react/tips/controlled-input-null-value.html
- christianalfoni/formsy-react#332
from formsy-react-components.
To clarify: if you initially pass undefined
or null
as the value prop, the component starts life as an "uncontrolled" component. Once you interact with the component, we set a value and react changes it to a "controlled" component, and issues the warning.
The dev
branch (alpha quality) has better proptype checking, so we should get earlier warnings about this in the future.
from formsy-react-components.
Aha! I see now in the playground source that value="" is passed to <Input />
:)
from formsy-react-components.
I had this warning message coming up for me when initialValues
were empty and format
returned undefined
; the fix was to have format
return ''
by default
from formsy-react-components.
In case it helps anyone, I just had the issue and solved it by changing value={this.state.location}
to value={this.state.location || ''}
(this.state.location
can be empty).
from formsy-react-components.
This is an utterly obscure and nonsensical error, it really doesn't help with most solutions. Im using Material UI for react and I'm using reject / accept buttons to close a dialog ( using redux to update the state accordingly) I have this warning, and I cannot get rid of it. Perhaps a better explanation of this controlled warning instead of more cryptic solutions?
from formsy-react-components.
Hi @stevematdavies — it is React that is raising this warning, we don't have any control over the wording. If you follow the advice set out above, it is avoidable. That said, I will add a note to the docs that we are dealing with controlled components, and that you shouldn't set a null
or undefined
initial state.
It's not clear to me how you're using formsy-react-components
in your project. If you can't get to the bottom of this problem, report back with more detail or a code example and we'll try to help.
from formsy-react-components.
I still have this error now in React 16, and I cannot get rid of it. I am using MaterialUI and I am adding text box values if the user has chosen to save them in browserStorage (a remember me functionality). If the user has not selected they are initially undefined, (setting an empty string prevents the input boxes from being used at all.)
Here is a snippet from the Login (Im also using redux) ,props.credentials is gotten from localStorage, and mappedTo Props via redux-connect
render() {
const { email, password } = (this.props.remember && this.props.credentials)
? this.props.credentials
: { email: undefined, password: undefined };
return (
.....
<TextField
floatingLabelText="Password"
name="password"
type="password"
value={password} // I'm assuming here is the issue (its either populated or undefined)
onBlur={this.harvestInputs} // could this also be a cause?
/>
Where am I going wrong?
from formsy-react-components.
I am trying to get rid of this error. I am using an input form with two text boxes and I have initialized their state's as an empty string. But still, React is raising this warning for one text box and thus, I am unable to update that textbox. Can anybody suggest me an alternative solution?
from formsy-react-components.
Hi @Dhrumil1808 sorry for late reply here is my code example to remove this error
class DemoPage extends React.Component
{
constructor(props) {
super(props);
this.handleClick = this.handleClick.bind(this);
this.handleInptChange = this.handleInptChange.bind(this);
this.state = {isToggleOn: true, input1: '', input2: ''};
}
handleClick() {
this.setState(prevState => ({
isToggleOn: !prevState.isToggleOn
}));
}
handleInptChange(event) {
this.setState({[event.target.name]: event.target.value});
}
render() {
return (
React.createElement(
'h1',
null,
'You are now on Demo Page!',
React.createElement(
'button',
{onClick: this.handleClick},
(this.state.isToggleOn) ? 'ON' : 'OFF'
),
React.createElement(
'input',
{type: 'text', onChange: this.handleInptChange, name: 'input1', value: this.state.input1},
),
React.createElement(
'input',
{type: 'text', onChange: this.handleInptChange, name: 'input2', value: this.state.input2},
)
)
);
}
}
export default DemoPage;
let me know if you still facing same error.
from formsy-react-components.
Hello @stevematdavies Which part of this is using formsy-react-components
? We don't have a TextField
component.
from formsy-react-components.
@SachaG this worked for me. Thanks!
from formsy-react-components.
@SachaG works for checkbox as well :)
(vanilla React, google brought me here)
from formsy-react-components.
Guys in your state just define the init value
state = {
title : ' ' // init value for the input title
}
from formsy-react-components.
it is props for me
from formsy-react-components.
Hello there, I'm going to lock down comments on this issue. There isn't really much to add that will help users of this package.
This page is ranking highly on google for the problem described, but I'm wary that more comments will add to the noise rather than the signal on this issue.
Happy coding ✊
from formsy-react-components.
Related Issues (20)
- React 16.1.1, Formsy 1.1: mixins problem HOT 4
- No Negative Numbers in Input HOT 4
- Change label prop to support PropTypes.node HOT 3
- Doubt/Feature: Prevent Select setValue HOT 2
- wrong install documentation ?
- Overriding icons HOT 1
- React.createElement: Type is invalid when creating a Form HOT 1
- Input component with numeric/alphanumeric/alpha value restriction HOT 2
- Select with numerical values HOT 1
- validatePristine textarea not displaying validation error HOT 4
- render elements within 'form-group'
- onChange is called before the value has been set on formsy
- Does this work with bootstrap 4? HOT 1
- New package release request HOT 2
- Refactor UNSAFE_componentWillReceiveProps
- Build correct releases HOT 5
- Editable input for Select component HOT 2
- Release of 2.0.0 - what remains? HOT 1
- add support for 2.1.0. and higher versions of formsy-react HOT 1
- Publish latest fixes to npm
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from formsy-react-components.