{"action":"created","issue":{"url":"https://api.github.com/repos/TroyAlford/react-jsx-parser/issues/49","repository_url":"https://api.github.com/repos/TroyAlford/react-jsx-parser","labels_url":"https://api.github.com/repos/TroyAlford/react-jsx-parser/issues/49/labels{/name}","comments_url":"https://api.github.com/repos/TroyAlford/react-jsx-parser/issues/49/comments","events_url":"https://api.github.com/repos/TroyAlford/react-jsx-parser/issues/49/events","html_url":"https://github.com/TroyAlford/react-jsx-parser/issues/49","id":310862954,"number":49,"title":"Bindings are not handled when receiving new props","user":{"login":"saendu","id":4354590,"avatar_url":"https://avatars0.githubusercontent.com/u/4354590?v=4","gravatar_id":"","url":"https://api.github.com/users/saendu","html_url":"https://github.com/saendu","followers_url":"https://api.github.com/users/saendu/followers","following_url":"https://api.github.com/users/saendu/following{/other_user}","gists_url":"https://api.github.com/users/saendu/gists{/gist_id}","starred_url":"https://api.github.com/users/saendu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saendu/subscriptions","organizations_url":"https://api.github.com/users/saendu/orgs","repos_url":"https://api.github.com/users/saendu/repos","events_url":"https://api.github.com/users/saendu/events{/privacy}","received_events_url":"https://api.github.com/users/saendu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-03T14:33:59Z","updated_at":"2018-04-06T11:10:32Z","closed_at":null,"author_association":"NONE","body":"Hi Troy\r\n\r\nI noticed that manipulating bindings via state do not reflect when the JsxParser component is rerendered. It looks like this is a by-design behaviour, since you do not handle new bindings as you handle blacklistedTags, blacklistedAttr and Jsx. Is there a possible reason for that? \r\n\r\nIf so I would like to show you an akward behaviour that should be handled. Consider the following code:\r\n```\r\nclass TitleComponent extends React.Component<any, any> {\r\n  public render() {\r\n    return(\r\n      <h1>{this.props.text}</h1>\r\n    );\r\n  }\r\n}\r\n\r\nexport class DynamicComponent extends React.Component<any, any> {\r\n  constructor(props) {\r\n      super(props);\r\n      this.state = {text: \"SOMETHING\"};\r\n\r\n      // change state 1\r\n      setTimeout(() => {\r\n        this.setState(previousState => {\r\n          console.log(\"change state 1\");\r\n          return { text: \"FIRST TITLE\" };\r\n        });\r\n      }, 2000);\r\n\r\n      // change state 2\r\n      setTimeout(() => {\r\n        this.setState(previousState => {\r\n          console.log(\"change state 2\");\r\n          return { text: \"SECOND TITLE\" };\r\n        });\r\n      }, 4000);\r\n  }\r\n\r\n  public render() { \r\n    \r\n    let textState = this.state.text; \r\n    \r\n    // only showing 'FIRST TITLE' after (4 sec)\r\n    return(\r\n      <JsxParser\r\n      bindings={{textState}}\r\n      components={{ TitleComponent }}\r\n      jsx={`<TitleComponent text={textState}/>`}\r\n      />\r\n    );\r\n  }\r\n}\r\n\r\n```\r\nThis code is not working like expected, since the title component only gets updated after the second state change - however - showing 'FIRST TITLE' which was the props.binding object from the frist change. \r\n\r\nThis could be fixed changing those two lines:\r\n\r\n```\r\nhandleNewProps = (props) => {\r\n     ...    \r\n    this.bindings = (props.bindings || {})\r\n    ...\r\n  }\r\n...\r\n parseExpression = (expression) => {\r\n    switch (expression.type) {\r\n      ...\r\n      case 'Identifier':\r\n        return this.bindings[expression.name] || undefined\r\n      ...\r\n    }\r\n  }\r\n```\r\n\r\n\r\nRegards,\r\nSandro\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/TroyAlford/react-jsx-parser/issues/comments/379222412","html_url":"https://github.com/TroyAlford/react-jsx-parser/issues/49#issuecomment-379222412","issue_url":"https://api.github.com/repos/TroyAlford/react-jsx-parser/issues/49","id":379222412,"user":{"login":"saendu","id":4354590,"avatar_url":"https://avatars0.githubusercontent.com/u/4354590?v=4","gravatar_id":"","url":"https://api.github.com/users/saendu","html_url":"https://github.com/saendu","followers_url":"https://api.github.com/users/saendu/followers","following_url":"https://api.github.com/users/saendu/following{/other_user}","gists_url":"https://api.github.com/users/saendu/gists{/gist_id}","starred_url":"https://api.github.com/users/saendu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saendu/subscriptions","organizations_url":"https://api.github.com/users/saendu/orgs","repos_url":"https://api.github.com/users/saendu/repos","events_url":"https://api.github.com/users/saendu/events{/privacy}","received_events_url":"https://api.github.com/users/saendu/received_events","type":"User","site_admin":false},"created_at":"2018-04-06T11:10:32Z","updated_at":"2018-04-06T11:10:32Z","author_association":"NONE","body":"#50 provided pull request"}}
{"actor":{"display_login":"saendu"}}