以下のようなlocalStorageでgetItemして文字列で返ってきた値があるとします。
</pre> var family = "families":"[ {\"id\":1,\"name\":\"asaba\",\"birthday\":\"1991-09-10\",\"relation\":{\"id\":2,\"name\":\"男\"}} ]", this.setState({family: family}) <pre>
これをそのままthis.state.families.map
をするとUncaught TypeError: this.state.data.map is not a functionで
エラーが返ってきます。
取り出した文字列を配列と同じように使うにはJSON.parse()を使って元の配列の形に
復元します。
</pre> var new_family = JSON.parse(family); this.setState({family: new_family}) this.state.families.map <pre>
これでmap関数に組み込むことができます。