Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how about passing as prop? #6

Closed
craigcosmo opened this issue Apr 12, 2016 · 1 comment
Closed

how about passing as prop? #6

craigcosmo opened this issue Apr 12, 2016 · 1 comment
Labels

Comments

@craigcosmo
Copy link

this is is hou

export default class Create extends React.Component{
    constructor(){
        super();
        this.state = {
            items: {
                firstName:'',
                lastName: '',
                address: {
                    address1:'',
                    address2:''
                }
            }
        };
    }
    render(){ 
        return(
            <div class="row">
                <Form states = {linkstate} /> 
            </div>
        )
    }
}

how could I access it in Form component?

@srph
Copy link
Owner

srph commented Apr 12, 2016

Ah, no, you use it directly to valueLink as instructed in the #Usage section. In your case, if you want to linkState the state from Create in Form, this might be how:

class Create extends React.Component {
  render() {
    return(
      <div class="row">
        <Form context={this} />
      </div>
    );
  }
}

class Form extends React.Component {
  render() {
    return (
      <form>
        <input valueLink={linkState(this.props.context, 'username')} />
      </form>
    );
  }
}

Feel free to open the issue if you the solution above doesn't do it for you.

@srph srph closed this as completed Apr 12, 2016
@srph srph added the question label Apr 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants