How to dinamically render the user data in a component on button click in React2019 Community Moderator ElectionHow do I detect a click outside an element?Trigger a button click with JavaScript on the Enter key in a text boxHow can I know which radio button is selected via jQuery?How to check a radio button with jQuery?How does data binding work in AngularJS?React “after render” code?react-router - pass props to handler componentCan you force a React component to rerender without calling setState?How to conditionally add attributes to React components?Detect click outside React component
Jem'Hadar, something strange about their life expectancy
Fair way to split coins
How can a new country break out from a developed country without war?
Justification failure in beamer enumerate list
How do you justify more code being written by following clean code practices?
Norwegian Refugee travel document
Unfrosted light bulb
Print last inputted byte
DisplayForm problem with pi in FractionBox
How to test the sharpness of a knife?
Is VPN a layer 3 concept?
Would mining huge amounts of resources on the Moon change its orbit?
Is this Pascal's Matrix?
How can an organ that provides biological immortality be unable to regenerate?
Does the Shadow Magic sorcerer's Eyes of the Dark feature work on all Darkness spells or just his/her own?
Do native speakers use "ultima" and "proxima" frequently in spoken English?
Have the tides ever turned twice on any open problem?
Why do I have a large white artefact on the rendered image?
Is xar preinstalled on macOS?
Error in master's thesis, I do not know what to do
Why are there no stars visible in cislunar space?
Interior of Set Notation
Is there any common country to visit for uk and schengen visa?
Why is "la Gestapo" feminine?
How to dinamically render the user data in a component on button click in React
2019 Community Moderator ElectionHow do I detect a click outside an element?Trigger a button click with JavaScript on the Enter key in a text boxHow can I know which radio button is selected via jQuery?How to check a radio button with jQuery?How does data binding work in AngularJS?React “after render” code?react-router - pass props to handler componentCan you force a React component to rerender without calling setState?How to conditionally add attributes to React components?Detect click outside React component
I'm new in React and got stuck on how can I achieve this.
After the user fills the field CEP from the first card and click on the button 'Gravar Dados', it shows a second card with all the information from the first card.
Template Picture
New Result Picture
What i need is dynamically create another card, under the second card with new info from the first card.
This is what i've done so far..
I have this component DadosPessoais.js
wich is the second card in the Template Picture:
render()
return (
<div className="card shadow mt-5" >
<div className="card-header">
<span>Dados Pessoais </span>
</div>
<div className="card-body">
<div className="row">
<div className="col-4">
<div>
<span>Cep: <strong>this.props.cep</strong></span>
</div>
<div>
<span>Bairro: <strong>this.props.bairro</strong></span>
</div>
</div>
<div className="col-5">
<div>
<span>Rua: <strong>this.props.rua</strong></span>
</div>
<div>
<span>Cidade: <strong>this.props.cidade</strong></span>
</div>
</div>
<div className="col-3">
<div>
<span>UF: <strong>this.props.uf</strong></span>
</div>
</div>
</div>
</div>
</div>
);
In my Home.js
i have a form with onSubmit
that calls mostrarDadosPessoais
function:
Function:
mostrarDadosPessoais(e)
e.preventDefault();
this.setState(
listaDados: this.state.listaDados.concat(
cep: e.target.value,
rua: e.target.value,
bairro: e.target.value,
cidade: e.target.value,
uf: e.target.value,
),
);
And my input components UserInput
, Should it be like this?:
<div className="col-3">
<UserInput name="Rua" Label="Rua" Id="Rua" value=this.state.rua Disabled />
</div>
<div className="col-3">
<UserInput name="Bairro" Label="Bairro" Id="Bairro" value=this.state.bairro Disabled />
</div>
<div className="col-3">
<UserInput name="Cidade" Label="Cidade" Id="Cidade" value=this.state.cidade Disabled />
</div>
<div className="col-1">
<UserInput name="UF" Label="UF" Id="UF" value=this.state.uf Disabled />
</div>
And to show the result card i've done this:
<div className="col-md-4">
this.state.listaDados.length === 0
? null
: this.state.listaDados.map((lista) => (<DadosPessoais ...lista />))
</div>
This is my state
:
this.state =
listaCidade: [],
listaDados: [],
Any ideas on how can i create another component and keep the values from the first one?
Thank you.
javascript reactjs components
add a comment |
I'm new in React and got stuck on how can I achieve this.
After the user fills the field CEP from the first card and click on the button 'Gravar Dados', it shows a second card with all the information from the first card.
Template Picture
New Result Picture
What i need is dynamically create another card, under the second card with new info from the first card.
This is what i've done so far..
I have this component DadosPessoais.js
wich is the second card in the Template Picture:
render()
return (
<div className="card shadow mt-5" >
<div className="card-header">
<span>Dados Pessoais </span>
</div>
<div className="card-body">
<div className="row">
<div className="col-4">
<div>
<span>Cep: <strong>this.props.cep</strong></span>
</div>
<div>
<span>Bairro: <strong>this.props.bairro</strong></span>
</div>
</div>
<div className="col-5">
<div>
<span>Rua: <strong>this.props.rua</strong></span>
</div>
<div>
<span>Cidade: <strong>this.props.cidade</strong></span>
</div>
</div>
<div className="col-3">
<div>
<span>UF: <strong>this.props.uf</strong></span>
</div>
</div>
</div>
</div>
</div>
);
In my Home.js
i have a form with onSubmit
that calls mostrarDadosPessoais
function:
Function:
mostrarDadosPessoais(e)
e.preventDefault();
this.setState(
listaDados: this.state.listaDados.concat(
cep: e.target.value,
rua: e.target.value,
bairro: e.target.value,
cidade: e.target.value,
uf: e.target.value,
),
);
And my input components UserInput
, Should it be like this?:
<div className="col-3">
<UserInput name="Rua" Label="Rua" Id="Rua" value=this.state.rua Disabled />
</div>
<div className="col-3">
<UserInput name="Bairro" Label="Bairro" Id="Bairro" value=this.state.bairro Disabled />
</div>
<div className="col-3">
<UserInput name="Cidade" Label="Cidade" Id="Cidade" value=this.state.cidade Disabled />
</div>
<div className="col-1">
<UserInput name="UF" Label="UF" Id="UF" value=this.state.uf Disabled />
</div>
And to show the result card i've done this:
<div className="col-md-4">
this.state.listaDados.length === 0
? null
: this.state.listaDados.map((lista) => (<DadosPessoais ...lista />))
</div>
This is my state
:
this.state =
listaCidade: [],
listaDados: [],
Any ideas on how can i create another component and keep the values from the first one?
Thank you.
javascript reactjs components
add a comment |
I'm new in React and got stuck on how can I achieve this.
After the user fills the field CEP from the first card and click on the button 'Gravar Dados', it shows a second card with all the information from the first card.
Template Picture
New Result Picture
What i need is dynamically create another card, under the second card with new info from the first card.
This is what i've done so far..
I have this component DadosPessoais.js
wich is the second card in the Template Picture:
render()
return (
<div className="card shadow mt-5" >
<div className="card-header">
<span>Dados Pessoais </span>
</div>
<div className="card-body">
<div className="row">
<div className="col-4">
<div>
<span>Cep: <strong>this.props.cep</strong></span>
</div>
<div>
<span>Bairro: <strong>this.props.bairro</strong></span>
</div>
</div>
<div className="col-5">
<div>
<span>Rua: <strong>this.props.rua</strong></span>
</div>
<div>
<span>Cidade: <strong>this.props.cidade</strong></span>
</div>
</div>
<div className="col-3">
<div>
<span>UF: <strong>this.props.uf</strong></span>
</div>
</div>
</div>
</div>
</div>
);
In my Home.js
i have a form with onSubmit
that calls mostrarDadosPessoais
function:
Function:
mostrarDadosPessoais(e)
e.preventDefault();
this.setState(
listaDados: this.state.listaDados.concat(
cep: e.target.value,
rua: e.target.value,
bairro: e.target.value,
cidade: e.target.value,
uf: e.target.value,
),
);
And my input components UserInput
, Should it be like this?:
<div className="col-3">
<UserInput name="Rua" Label="Rua" Id="Rua" value=this.state.rua Disabled />
</div>
<div className="col-3">
<UserInput name="Bairro" Label="Bairro" Id="Bairro" value=this.state.bairro Disabled />
</div>
<div className="col-3">
<UserInput name="Cidade" Label="Cidade" Id="Cidade" value=this.state.cidade Disabled />
</div>
<div className="col-1">
<UserInput name="UF" Label="UF" Id="UF" value=this.state.uf Disabled />
</div>
And to show the result card i've done this:
<div className="col-md-4">
this.state.listaDados.length === 0
? null
: this.state.listaDados.map((lista) => (<DadosPessoais ...lista />))
</div>
This is my state
:
this.state =
listaCidade: [],
listaDados: [],
Any ideas on how can i create another component and keep the values from the first one?
Thank you.
javascript reactjs components
I'm new in React and got stuck on how can I achieve this.
After the user fills the field CEP from the first card and click on the button 'Gravar Dados', it shows a second card with all the information from the first card.
Template Picture
New Result Picture
What i need is dynamically create another card, under the second card with new info from the first card.
This is what i've done so far..
I have this component DadosPessoais.js
wich is the second card in the Template Picture:
render()
return (
<div className="card shadow mt-5" >
<div className="card-header">
<span>Dados Pessoais </span>
</div>
<div className="card-body">
<div className="row">
<div className="col-4">
<div>
<span>Cep: <strong>this.props.cep</strong></span>
</div>
<div>
<span>Bairro: <strong>this.props.bairro</strong></span>
</div>
</div>
<div className="col-5">
<div>
<span>Rua: <strong>this.props.rua</strong></span>
</div>
<div>
<span>Cidade: <strong>this.props.cidade</strong></span>
</div>
</div>
<div className="col-3">
<div>
<span>UF: <strong>this.props.uf</strong></span>
</div>
</div>
</div>
</div>
</div>
);
In my Home.js
i have a form with onSubmit
that calls mostrarDadosPessoais
function:
Function:
mostrarDadosPessoais(e)
e.preventDefault();
this.setState(
listaDados: this.state.listaDados.concat(
cep: e.target.value,
rua: e.target.value,
bairro: e.target.value,
cidade: e.target.value,
uf: e.target.value,
),
);
And my input components UserInput
, Should it be like this?:
<div className="col-3">
<UserInput name="Rua" Label="Rua" Id="Rua" value=this.state.rua Disabled />
</div>
<div className="col-3">
<UserInput name="Bairro" Label="Bairro" Id="Bairro" value=this.state.bairro Disabled />
</div>
<div className="col-3">
<UserInput name="Cidade" Label="Cidade" Id="Cidade" value=this.state.cidade Disabled />
</div>
<div className="col-1">
<UserInput name="UF" Label="UF" Id="UF" value=this.state.uf Disabled />
</div>
And to show the result card i've done this:
<div className="col-md-4">
this.state.listaDados.length === 0
? null
: this.state.listaDados.map((lista) => (<DadosPessoais ...lista />))
</div>
This is my state
:
this.state =
listaCidade: [],
listaDados: [],
Any ideas on how can i create another component and keep the values from the first one?
Thank you.
javascript reactjs components
javascript reactjs components
edited Mar 12 at 0:19
Vinix Gonzalez
asked Mar 7 at 18:54
Vinix GonzalezVinix Gonzalez
53
53
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
If I understand well, you need a list of elements, displayed on the right, that will show user-entered data. You need the user to be able to enter many addresses through the form on the left, and you want each address to display on the right.
I would solve this with a component that contains state for all the elements you need to display in an array that you update on a form submit event, because that's an easy event to work with when you have forms with lots of fields. You can grab the values of the components through the event object e.
class StateContainer extends Component
constructor()
super(props);
this.state =
addresses: [],
mostrarDadosPessoais(e)
e.preventDefault();
this.setState(
listaDados: this.state.listaDados.concat(
cep: e.target.cep.value,
rua: e.target.rua.value,
// etc, etc
),
)
render()
return (
<div>
<form handleSubmit=this.mostrarDadosPessoais>
/* left-side form */
<input name="msg" />
<button type="submit"></button>
</form>
<div>
/* right-side list of elements */
this.state.addresses.length === 0
? null
: this.state.addresses.map(
(address) => (<DadosPessoais ...address />)
)
</div>
</div>
);
Thanks Thomas, but i've never used refs before, can you explain how to use in my case? I dont know how can i create a new component if the component was once created.
– Vinix Gonzalez
Mar 7 at 20:13
In your mockup, you have a box with inputs and a box to the right that displays those values. Have you successfully gotten the box on the right to show up? If you have gotten the box on the right to show up, you can use the same technique to make the 'next card' show up - a 'show next' flag in the same element's state.
– Thomas Ingalls
Mar 7 at 22:14
I think I misunderstood your requirements in my first response, I re-read your question and I'm going to update my answer.
– Thomas Ingalls
Mar 7 at 22:17
i've tried your solution but still didnt achieve what i need, i guess i'm doing something wrong, how should i set the state? Now im getting an empty second card, i did this in the mostrarDadosPessoais method: this.setState( listaDados: [ cep: this.state.cep, rua: this.state.rua, bairro: this.state.bairro, cidade: this.state.cidade, uf: this.state.uf , msg: this.state.listaDados ] )
– Vinix Gonzalez
Mar 11 at 20:49
You can deletemsg: this.state.listaDados
, then it might work. That was an example I used to avoid typing out all of this --cep: this.state.cep, rua: this.state.rua, bairro: this.state.bairro, cidade: this.state.cidade, uf: this.state.uf
. Sorry for the misleading example!
– Thomas Ingalls
Mar 11 at 20:55
|
show 4 more comments
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%2f55050921%2fhow-to-dinamically-render-the-user-data-in-a-component-on-button-click-in-react%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
If I understand well, you need a list of elements, displayed on the right, that will show user-entered data. You need the user to be able to enter many addresses through the form on the left, and you want each address to display on the right.
I would solve this with a component that contains state for all the elements you need to display in an array that you update on a form submit event, because that's an easy event to work with when you have forms with lots of fields. You can grab the values of the components through the event object e.
class StateContainer extends Component
constructor()
super(props);
this.state =
addresses: [],
mostrarDadosPessoais(e)
e.preventDefault();
this.setState(
listaDados: this.state.listaDados.concat(
cep: e.target.cep.value,
rua: e.target.rua.value,
// etc, etc
),
)
render()
return (
<div>
<form handleSubmit=this.mostrarDadosPessoais>
/* left-side form */
<input name="msg" />
<button type="submit"></button>
</form>
<div>
/* right-side list of elements */
this.state.addresses.length === 0
? null
: this.state.addresses.map(
(address) => (<DadosPessoais ...address />)
)
</div>
</div>
);
Thanks Thomas, but i've never used refs before, can you explain how to use in my case? I dont know how can i create a new component if the component was once created.
– Vinix Gonzalez
Mar 7 at 20:13
In your mockup, you have a box with inputs and a box to the right that displays those values. Have you successfully gotten the box on the right to show up? If you have gotten the box on the right to show up, you can use the same technique to make the 'next card' show up - a 'show next' flag in the same element's state.
– Thomas Ingalls
Mar 7 at 22:14
I think I misunderstood your requirements in my first response, I re-read your question and I'm going to update my answer.
– Thomas Ingalls
Mar 7 at 22:17
i've tried your solution but still didnt achieve what i need, i guess i'm doing something wrong, how should i set the state? Now im getting an empty second card, i did this in the mostrarDadosPessoais method: this.setState( listaDados: [ cep: this.state.cep, rua: this.state.rua, bairro: this.state.bairro, cidade: this.state.cidade, uf: this.state.uf , msg: this.state.listaDados ] )
– Vinix Gonzalez
Mar 11 at 20:49
You can deletemsg: this.state.listaDados
, then it might work. That was an example I used to avoid typing out all of this --cep: this.state.cep, rua: this.state.rua, bairro: this.state.bairro, cidade: this.state.cidade, uf: this.state.uf
. Sorry for the misleading example!
– Thomas Ingalls
Mar 11 at 20:55
|
show 4 more comments
If I understand well, you need a list of elements, displayed on the right, that will show user-entered data. You need the user to be able to enter many addresses through the form on the left, and you want each address to display on the right.
I would solve this with a component that contains state for all the elements you need to display in an array that you update on a form submit event, because that's an easy event to work with when you have forms with lots of fields. You can grab the values of the components through the event object e.
class StateContainer extends Component
constructor()
super(props);
this.state =
addresses: [],
mostrarDadosPessoais(e)
e.preventDefault();
this.setState(
listaDados: this.state.listaDados.concat(
cep: e.target.cep.value,
rua: e.target.rua.value,
// etc, etc
),
)
render()
return (
<div>
<form handleSubmit=this.mostrarDadosPessoais>
/* left-side form */
<input name="msg" />
<button type="submit"></button>
</form>
<div>
/* right-side list of elements */
this.state.addresses.length === 0
? null
: this.state.addresses.map(
(address) => (<DadosPessoais ...address />)
)
</div>
</div>
);
Thanks Thomas, but i've never used refs before, can you explain how to use in my case? I dont know how can i create a new component if the component was once created.
– Vinix Gonzalez
Mar 7 at 20:13
In your mockup, you have a box with inputs and a box to the right that displays those values. Have you successfully gotten the box on the right to show up? If you have gotten the box on the right to show up, you can use the same technique to make the 'next card' show up - a 'show next' flag in the same element's state.
– Thomas Ingalls
Mar 7 at 22:14
I think I misunderstood your requirements in my first response, I re-read your question and I'm going to update my answer.
– Thomas Ingalls
Mar 7 at 22:17
i've tried your solution but still didnt achieve what i need, i guess i'm doing something wrong, how should i set the state? Now im getting an empty second card, i did this in the mostrarDadosPessoais method: this.setState( listaDados: [ cep: this.state.cep, rua: this.state.rua, bairro: this.state.bairro, cidade: this.state.cidade, uf: this.state.uf , msg: this.state.listaDados ] )
– Vinix Gonzalez
Mar 11 at 20:49
You can deletemsg: this.state.listaDados
, then it might work. That was an example I used to avoid typing out all of this --cep: this.state.cep, rua: this.state.rua, bairro: this.state.bairro, cidade: this.state.cidade, uf: this.state.uf
. Sorry for the misleading example!
– Thomas Ingalls
Mar 11 at 20:55
|
show 4 more comments
If I understand well, you need a list of elements, displayed on the right, that will show user-entered data. You need the user to be able to enter many addresses through the form on the left, and you want each address to display on the right.
I would solve this with a component that contains state for all the elements you need to display in an array that you update on a form submit event, because that's an easy event to work with when you have forms with lots of fields. You can grab the values of the components through the event object e.
class StateContainer extends Component
constructor()
super(props);
this.state =
addresses: [],
mostrarDadosPessoais(e)
e.preventDefault();
this.setState(
listaDados: this.state.listaDados.concat(
cep: e.target.cep.value,
rua: e.target.rua.value,
// etc, etc
),
)
render()
return (
<div>
<form handleSubmit=this.mostrarDadosPessoais>
/* left-side form */
<input name="msg" />
<button type="submit"></button>
</form>
<div>
/* right-side list of elements */
this.state.addresses.length === 0
? null
: this.state.addresses.map(
(address) => (<DadosPessoais ...address />)
)
</div>
</div>
);
If I understand well, you need a list of elements, displayed on the right, that will show user-entered data. You need the user to be able to enter many addresses through the form on the left, and you want each address to display on the right.
I would solve this with a component that contains state for all the elements you need to display in an array that you update on a form submit event, because that's an easy event to work with when you have forms with lots of fields. You can grab the values of the components through the event object e.
class StateContainer extends Component
constructor()
super(props);
this.state =
addresses: [],
mostrarDadosPessoais(e)
e.preventDefault();
this.setState(
listaDados: this.state.listaDados.concat(
cep: e.target.cep.value,
rua: e.target.rua.value,
// etc, etc
),
)
render()
return (
<div>
<form handleSubmit=this.mostrarDadosPessoais>
/* left-side form */
<input name="msg" />
<button type="submit"></button>
</form>
<div>
/* right-side list of elements */
this.state.addresses.length === 0
? null
: this.state.addresses.map(
(address) => (<DadosPessoais ...address />)
)
</div>
</div>
);
edited Mar 11 at 21:06
answered Mar 7 at 19:14
Thomas IngallsThomas Ingalls
393410
393410
Thanks Thomas, but i've never used refs before, can you explain how to use in my case? I dont know how can i create a new component if the component was once created.
– Vinix Gonzalez
Mar 7 at 20:13
In your mockup, you have a box with inputs and a box to the right that displays those values. Have you successfully gotten the box on the right to show up? If you have gotten the box on the right to show up, you can use the same technique to make the 'next card' show up - a 'show next' flag in the same element's state.
– Thomas Ingalls
Mar 7 at 22:14
I think I misunderstood your requirements in my first response, I re-read your question and I'm going to update my answer.
– Thomas Ingalls
Mar 7 at 22:17
i've tried your solution but still didnt achieve what i need, i guess i'm doing something wrong, how should i set the state? Now im getting an empty second card, i did this in the mostrarDadosPessoais method: this.setState( listaDados: [ cep: this.state.cep, rua: this.state.rua, bairro: this.state.bairro, cidade: this.state.cidade, uf: this.state.uf , msg: this.state.listaDados ] )
– Vinix Gonzalez
Mar 11 at 20:49
You can deletemsg: this.state.listaDados
, then it might work. That was an example I used to avoid typing out all of this --cep: this.state.cep, rua: this.state.rua, bairro: this.state.bairro, cidade: this.state.cidade, uf: this.state.uf
. Sorry for the misleading example!
– Thomas Ingalls
Mar 11 at 20:55
|
show 4 more comments
Thanks Thomas, but i've never used refs before, can you explain how to use in my case? I dont know how can i create a new component if the component was once created.
– Vinix Gonzalez
Mar 7 at 20:13
In your mockup, you have a box with inputs and a box to the right that displays those values. Have you successfully gotten the box on the right to show up? If you have gotten the box on the right to show up, you can use the same technique to make the 'next card' show up - a 'show next' flag in the same element's state.
– Thomas Ingalls
Mar 7 at 22:14
I think I misunderstood your requirements in my first response, I re-read your question and I'm going to update my answer.
– Thomas Ingalls
Mar 7 at 22:17
i've tried your solution but still didnt achieve what i need, i guess i'm doing something wrong, how should i set the state? Now im getting an empty second card, i did this in the mostrarDadosPessoais method: this.setState( listaDados: [ cep: this.state.cep, rua: this.state.rua, bairro: this.state.bairro, cidade: this.state.cidade, uf: this.state.uf , msg: this.state.listaDados ] )
– Vinix Gonzalez
Mar 11 at 20:49
You can deletemsg: this.state.listaDados
, then it might work. That was an example I used to avoid typing out all of this --cep: this.state.cep, rua: this.state.rua, bairro: this.state.bairro, cidade: this.state.cidade, uf: this.state.uf
. Sorry for the misleading example!
– Thomas Ingalls
Mar 11 at 20:55
Thanks Thomas, but i've never used refs before, can you explain how to use in my case? I dont know how can i create a new component if the component was once created.
– Vinix Gonzalez
Mar 7 at 20:13
Thanks Thomas, but i've never used refs before, can you explain how to use in my case? I dont know how can i create a new component if the component was once created.
– Vinix Gonzalez
Mar 7 at 20:13
In your mockup, you have a box with inputs and a box to the right that displays those values. Have you successfully gotten the box on the right to show up? If you have gotten the box on the right to show up, you can use the same technique to make the 'next card' show up - a 'show next' flag in the same element's state.
– Thomas Ingalls
Mar 7 at 22:14
In your mockup, you have a box with inputs and a box to the right that displays those values. Have you successfully gotten the box on the right to show up? If you have gotten the box on the right to show up, you can use the same technique to make the 'next card' show up - a 'show next' flag in the same element's state.
– Thomas Ingalls
Mar 7 at 22:14
I think I misunderstood your requirements in my first response, I re-read your question and I'm going to update my answer.
– Thomas Ingalls
Mar 7 at 22:17
I think I misunderstood your requirements in my first response, I re-read your question and I'm going to update my answer.
– Thomas Ingalls
Mar 7 at 22:17
i've tried your solution but still didnt achieve what i need, i guess i'm doing something wrong, how should i set the state? Now im getting an empty second card, i did this in the mostrarDadosPessoais method: this.setState( listaDados: [ cep: this.state.cep, rua: this.state.rua, bairro: this.state.bairro, cidade: this.state.cidade, uf: this.state.uf , msg: this.state.listaDados ] )
– Vinix Gonzalez
Mar 11 at 20:49
i've tried your solution but still didnt achieve what i need, i guess i'm doing something wrong, how should i set the state? Now im getting an empty second card, i did this in the mostrarDadosPessoais method: this.setState( listaDados: [ cep: this.state.cep, rua: this.state.rua, bairro: this.state.bairro, cidade: this.state.cidade, uf: this.state.uf , msg: this.state.listaDados ] )
– Vinix Gonzalez
Mar 11 at 20:49
You can delete
msg: this.state.listaDados
, then it might work. That was an example I used to avoid typing out all of this -- cep: this.state.cep, rua: this.state.rua, bairro: this.state.bairro, cidade: this.state.cidade, uf: this.state.uf
. Sorry for the misleading example!– Thomas Ingalls
Mar 11 at 20:55
You can delete
msg: this.state.listaDados
, then it might work. That was an example I used to avoid typing out all of this -- cep: this.state.cep, rua: this.state.rua, bairro: this.state.bairro, cidade: this.state.cidade, uf: this.state.uf
. Sorry for the misleading example!– Thomas Ingalls
Mar 11 at 20:55
|
show 4 more comments
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%2f55050921%2fhow-to-dinamically-render-the-user-data-in-a-component-on-button-click-in-react%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