1

I already saw a similar question from someone else here and the answer is pretty clear. Yet, if you're working with in a redux container, the states turn into props through the mapStateToProps function.

How is it then correct to proceed if I want e.g. my text-div to turn into an input, when I click or double-click on it? I don't have any code yet, I'm wondering about the theory.

3
  • Couldn't the container component have props and state? The props can come from redux, and the state can be initialized in the component and can be used to determine which sort of component to use. Unless if I am missing something in your question, I think you may be over thinking it. Commented Jun 6, 2017 at 20:07
  • I'm not quite sure. I tried to have state in it, but didn't work out. From a tutorial, I understood that all states turn into props in the containers. Maybe I'm wrong. It would be very important to find it out. Commented Jun 6, 2017 at 20:15
  • 1
    That is not the case. Props only refers to what is being passed in to a component. This can mean it was passed from a parent to a child, or from redux to a component. State refers to data that was initialized within the component, and it will always stay as state in that component. Commented Jun 6, 2017 at 20:17

1 Answer 1

2

The components get store state data passed in as props, but they can also have their own state. So in your case, your component would use it's own state to handle the toggling of div to input. If for some reason you wanted it to be saved in the store instead, you would fire off an action to toggle the view and then use the prop from the store in your render method.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you Chase, that sounds great. I will give it a try tomorrow!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.