Reputation: 175
I have this React component.I would like to change the value of the variable title in the function test() .
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { ValueStore } from '../../host/redux/list.store';
import { removeLast } from '../../host/redux/list.action';
import { Injector } from '@angular/core';
import { Model } from '../../model';
interface ReactChildComponentViewProps {
title: String;
store: ValueStore;
injector: Injector;
}
var ReactChildComponent = React.createClass<ReactChildComponentViewProps, any>({
getInitialState: function() {
console.log( 'Using Angular 2 injector in React body, model.uuid: ' + model.uuid );
},
render: function() {
var title = "Ttile";
return(
<div>
{title}
</div>
);
}
});
export class ReactChildComponentView {
static initialize(title, store: ValueStore, containerId: string, injector: Injector) {
ReactDOM.render(<ReactChildComponent title={title} store={store} injector={injector}/>, document.getElementById(containerId));
}
static test() {
console.log('Test');
//this.props.store.dispatch( removeLast() );
}
}
Is it possible to change the value of title in function test().Is yes How can I do this?
Upvotes: 0
Views: 9408
Reputation: 406
As far as I understand you want to make title
dynamic ?
You need to put title
to the state, then you can easly manipulate it with this.setState({title:"whatever"});
and in order to display it you need to write this.state.title
Upvotes: 2