Why doesn't redux-form pass in the value from an option field as prop in the submit function?
The Problem
I have 2 simple redux form's.
They consist title
and subTitle
fields of type text
.
One of the two forms uses another field type select
.
I pass in an option like this:
<Field name="test" component="select">
<option value="test">test</option>
</Field>
So I fill out the form and console log the props like this:
The general Form submit:
<Form onSubmit={handleSubmit(submitTopic)}>
The actual function that runs:
const submitTopic = props => {
console.log(props);
// dispatch(createTopic(test, topicTitle, topicSubTitle));
};
So I expect to see the title as the string I typed in in the form and the subTitle as the string I typed in. (works for both forms)
I also expect to see a third property called "test" with the string "test" as value in the second form.
But it's actually undefined
The Code
Here is the link to my repo:
https://github.com/dhuber666/CodeHUB
The files where all this happens are here:
The Admin.js file is where I import it and run it.
I made sure that each form has it's unique identifier
when using the reduxForm
helper method.
A minimal Example to test out on Codesandbox
https://codesandbox.io/s/w0mqnwqz9w
Here I recreated the app but just with the bare mininum to test this out.
And I have the same problem here. I don't get the option value passed in into props.
The console.log for the props is in the file Form
at line number 10
Thank you for your help!
javascript reactjs redux-form
add a comment |
The Problem
I have 2 simple redux form's.
They consist title
and subTitle
fields of type text
.
One of the two forms uses another field type select
.
I pass in an option like this:
<Field name="test" component="select">
<option value="test">test</option>
</Field>
So I fill out the form and console log the props like this:
The general Form submit:
<Form onSubmit={handleSubmit(submitTopic)}>
The actual function that runs:
const submitTopic = props => {
console.log(props);
// dispatch(createTopic(test, topicTitle, topicSubTitle));
};
So I expect to see the title as the string I typed in in the form and the subTitle as the string I typed in. (works for both forms)
I also expect to see a third property called "test" with the string "test" as value in the second form.
But it's actually undefined
The Code
Here is the link to my repo:
https://github.com/dhuber666/CodeHUB
The files where all this happens are here:
The Admin.js file is where I import it and run it.
I made sure that each form has it's unique identifier
when using the reduxForm
helper method.
A minimal Example to test out on Codesandbox
https://codesandbox.io/s/w0mqnwqz9w
Here I recreated the app but just with the bare mininum to test this out.
And I have the same problem here. I don't get the option value passed in into props.
The console.log for the props is in the file Form
at line number 10
Thank you for your help!
javascript reactjs redux-form
I am able to see the "test" value in console
– Avinash
Nov 25 '18 at 17:44
That is very strange. Here is my console.log output: Object {topicTitle: "Javascript", topicSubTitle: "asdfasdfasdfasdf"} topicTitle: "Javascript" topicSubTitle: "asdfasdfasdfasdf"
– GeraltDieSocke
Nov 25 '18 at 18:05
add a comment |
The Problem
I have 2 simple redux form's.
They consist title
and subTitle
fields of type text
.
One of the two forms uses another field type select
.
I pass in an option like this:
<Field name="test" component="select">
<option value="test">test</option>
</Field>
So I fill out the form and console log the props like this:
The general Form submit:
<Form onSubmit={handleSubmit(submitTopic)}>
The actual function that runs:
const submitTopic = props => {
console.log(props);
// dispatch(createTopic(test, topicTitle, topicSubTitle));
};
So I expect to see the title as the string I typed in in the form and the subTitle as the string I typed in. (works for both forms)
I also expect to see a third property called "test" with the string "test" as value in the second form.
But it's actually undefined
The Code
Here is the link to my repo:
https://github.com/dhuber666/CodeHUB
The files where all this happens are here:
The Admin.js file is where I import it and run it.
I made sure that each form has it's unique identifier
when using the reduxForm
helper method.
A minimal Example to test out on Codesandbox
https://codesandbox.io/s/w0mqnwqz9w
Here I recreated the app but just with the bare mininum to test this out.
And I have the same problem here. I don't get the option value passed in into props.
The console.log for the props is in the file Form
at line number 10
Thank you for your help!
javascript reactjs redux-form
The Problem
I have 2 simple redux form's.
They consist title
and subTitle
fields of type text
.
One of the two forms uses another field type select
.
I pass in an option like this:
<Field name="test" component="select">
<option value="test">test</option>
</Field>
So I fill out the form and console log the props like this:
The general Form submit:
<Form onSubmit={handleSubmit(submitTopic)}>
The actual function that runs:
const submitTopic = props => {
console.log(props);
// dispatch(createTopic(test, topicTitle, topicSubTitle));
};
So I expect to see the title as the string I typed in in the form and the subTitle as the string I typed in. (works for both forms)
I also expect to see a third property called "test" with the string "test" as value in the second form.
But it's actually undefined
The Code
Here is the link to my repo:
https://github.com/dhuber666/CodeHUB
The files where all this happens are here:
The Admin.js file is where I import it and run it.
I made sure that each form has it's unique identifier
when using the reduxForm
helper method.
A minimal Example to test out on Codesandbox
https://codesandbox.io/s/w0mqnwqz9w
Here I recreated the app but just with the bare mininum to test this out.
And I have the same problem here. I don't get the option value passed in into props.
The console.log for the props is in the file Form
at line number 10
Thank you for your help!
javascript reactjs redux-form
javascript reactjs redux-form
asked Nov 25 '18 at 17:37
GeraltDieSockeGeraltDieSocke
308216
308216
I am able to see the "test" value in console
– Avinash
Nov 25 '18 at 17:44
That is very strange. Here is my console.log output: Object {topicTitle: "Javascript", topicSubTitle: "asdfasdfasdfasdf"} topicTitle: "Javascript" topicSubTitle: "asdfasdfasdfasdf"
– GeraltDieSocke
Nov 25 '18 at 18:05
add a comment |
I am able to see the "test" value in console
– Avinash
Nov 25 '18 at 17:44
That is very strange. Here is my console.log output: Object {topicTitle: "Javascript", topicSubTitle: "asdfasdfasdfasdf"} topicTitle: "Javascript" topicSubTitle: "asdfasdfasdfasdf"
– GeraltDieSocke
Nov 25 '18 at 18:05
I am able to see the "test" value in console
– Avinash
Nov 25 '18 at 17:44
I am able to see the "test" value in console
– Avinash
Nov 25 '18 at 17:44
That is very strange. Here is my console.log output: Object {topicTitle: "Javascript", topicSubTitle: "asdfasdfasdfasdf"} topicTitle: "Javascript" topicSubTitle: "asdfasdfasdfasdf"
– GeraltDieSocke
Nov 25 '18 at 18:05
That is very strange. Here is my console.log output: Object {topicTitle: "Javascript", topicSubTitle: "asdfasdfasdfasdf"} topicTitle: "Javascript" topicSubTitle: "asdfasdfasdfasdf"
– GeraltDieSocke
Nov 25 '18 at 18:05
add a comment |
1 Answer
1
active
oldest
votes
It works when you try to select an option, it doesn't work when you directly submit without selecting because the value is undefined initially until onChange event is triggered.
if you want to skip that, You can provide a default value by creating a wrapper component for select.
Thank you so much, that was it. OMG :D
– GeraltDieSocke
Nov 25 '18 at 20:00
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53470126%2fwhy-doesnt-redux-form-pass-in-the-value-from-an-option-field-as-prop-in-the-sub%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
It works when you try to select an option, it doesn't work when you directly submit without selecting because the value is undefined initially until onChange event is triggered.
if you want to skip that, You can provide a default value by creating a wrapper component for select.
Thank you so much, that was it. OMG :D
– GeraltDieSocke
Nov 25 '18 at 20:00
add a comment |
It works when you try to select an option, it doesn't work when you directly submit without selecting because the value is undefined initially until onChange event is triggered.
if you want to skip that, You can provide a default value by creating a wrapper component for select.
Thank you so much, that was it. OMG :D
– GeraltDieSocke
Nov 25 '18 at 20:00
add a comment |
It works when you try to select an option, it doesn't work when you directly submit without selecting because the value is undefined initially until onChange event is triggered.
if you want to skip that, You can provide a default value by creating a wrapper component for select.
It works when you try to select an option, it doesn't work when you directly submit without selecting because the value is undefined initially until onChange event is triggered.
if you want to skip that, You can provide a default value by creating a wrapper component for select.
answered Nov 25 '18 at 18:26
AvinashAvinash
365212
365212
Thank you so much, that was it. OMG :D
– GeraltDieSocke
Nov 25 '18 at 20:00
add a comment |
Thank you so much, that was it. OMG :D
– GeraltDieSocke
Nov 25 '18 at 20:00
Thank you so much, that was it. OMG :D
– GeraltDieSocke
Nov 25 '18 at 20:00
Thank you so much, that was it. OMG :D
– GeraltDieSocke
Nov 25 '18 at 20:00
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53470126%2fwhy-doesnt-redux-form-pass-in-the-value-from-an-option-field-as-prop-in-the-sub%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I am able to see the "test" value in console
– Avinash
Nov 25 '18 at 17:44
That is very strange. Here is my console.log output: Object {topicTitle: "Javascript", topicSubTitle: "asdfasdfasdfasdf"} topicTitle: "Javascript" topicSubTitle: "asdfasdfasdfasdf"
– GeraltDieSocke
Nov 25 '18 at 18:05