Meteor + React : Update Parent when Children/Parent change state


#1

I have a class TourEditor that is children and parent of a tourEditor class that processes the form when submitted. I would like the parent tourEditor to update the compoment object whenever the function updateFiles(files) is called in the children but unfortunately it is only saving the initial state of the children and not updating the state. Any ideas on how can this be solved?

TourEditor.js

export default class TourEditor extends React.Component {

  constructor(props){
    super(props);
    this.state = {"files": []};
    this.updateFiles = this.updateFiles.bind(this);
  }

  componentDidMount() {
    tourEditor({ component: this });
  }

  updateFiles(files) {
      this.setState({
          files: files
      });
  }

  render() {
    const { tour } = this.props;
    return (<form
      ref={ form => (this.tourEditorForm = form) }
      onSubmit={ event => event.preventDefault() }
    >
      <FormGroup>
       //....
      </FormGroup>
    </form>);
  }
}

tourEditor.js

export default function tourEditor(options) {
  console.log(options);
  component = options.component;
  validate();
}

#2

You should look into something like Redux for sharing the state among components.