<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dieldore</title>
    <description>The latest articles on DEV Community by Dieldore (@dieldore).</description>
    <link>https://dev.to/dieldore</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F353887%2F5c83c67e-bd1c-472d-88d5-95f03787e986.jpeg</url>
      <title>DEV Community: Dieldore</title>
      <link>https://dev.to/dieldore</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dieldore"/>
    <language>en</language>
    <item>
      <title>can't declare url and path variables useRouteMatch in class</title>
      <dc:creator>Dieldore</dc:creator>
      <pubDate>Wed, 25 Mar 2020 04:10:42 +0000</pubDate>
      <link>https://dev.to/dieldore/can-t-declare-url-and-path-variables-useroutematch-in-class-5dkl</link>
      <guid>https://dev.to/dieldore/can-t-declare-url-and-path-variables-useroutematch-in-class-5dkl</guid>
      <description>&lt;p&gt;Now i do so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;constructor(props) {
    super(props);
    let r = useRouteMatch();
    this.path = r.path;
    this.url = r.url;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;but this does not work and throws errors: url is not defined, if i use them in render()&lt;br&gt;
This code is indicated in the documentation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let {path, url} = useRouteMatch();
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It works for functional programming, not for class. How to declare these variables in this as one line? Or something&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How to change context from a child</title>
      <dc:creator>Dieldore</dc:creator>
      <pubDate>Mon, 23 Mar 2020 21:58:50 +0000</pubDate>
      <link>https://dev.to/dieldore/how-to-change-context-from-a-child-3jjb</link>
      <guid>https://dev.to/dieldore/how-to-change-context-from-a-child-3jjb</guid>
      <description>&lt;p&gt;Simple code&lt;br&gt;
&lt;a href="https://codesandbox.io/s/gracious-jennings-ugqzd"&gt;https://codesandbox.io/s/gracious-jennings-ugqzd&lt;/a&gt;&lt;br&gt;
I need to change the value of number from class Two. For some reason, a simple change does not work&lt;/p&gt;

</description>
      <category>react</category>
    </item>
    <item>
      <title>Huge problem: code does not go further than await</title>
      <dc:creator>Dieldore</dc:creator>
      <pubDate>Mon, 23 Mar 2020 20:39:26 +0000</pubDate>
      <link>https://dev.to/dieldore/huge-problem-code-does-not-go-further-than-await-22fk</link>
      <guid>https://dev.to/dieldore/huge-problem-code-does-not-go-further-than-await-22fk</guid>
      <description>&lt;p&gt;Code in App.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;componentDidMount() {
    this.getAccountData();
}
async getAccountData() {
    try {
      let FD = new FormData();
      FD.append('test', true);
      let Q = fetch('/ajax/get', {
        method: 'POST',
        body: FD
      });
      let data = await Q.json();
      console.log(data);
      this.setState({
        id: data.id,
        name: data.name
      });
    }
    catch(e) {
      console.log('error');
    };
  }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;After await is called, it gets the data in JSON. But if you put console.log after it, then they do not work, so setState also breaks my application. debugger also does not work there.&lt;br&gt;
I am using firefox 68.6 and 80.0.3987.132&lt;/p&gt;

</description>
      <category>react</category>
    </item>
    <item>
      <title>variable passed through context does not change in the child when changing in the parent and vice versa</title>
      <dc:creator>Dieldore</dc:creator>
      <pubDate>Sun, 22 Mar 2020 10:53:50 +0000</pubDate>
      <link>https://dev.to/dieldore/variable-passed-through-context-does-not-change-in-the-child-when-changing-in-the-parent-and-vice-versa-1ib6</link>
      <guid>https://dev.to/dieldore/variable-passed-through-context-does-not-change-in-the-child-when-changing-in-the-parent-and-vice-versa-1ib6</guid>
      <description>&lt;p&gt;I learned this manual &lt;a href="https://reactjs.org/docs/context.html"&gt;https://reactjs.org/docs/context.html&lt;/a&gt;&lt;br&gt;
And wrote this code&lt;/p&gt;

&lt;p&gt;UserContext.js:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
const UserContext = React.createContext();
export default UserContext;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;App.js:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      id: '',
      name: ''
    };
  }
  componentDidMount() {
    this.getAccountData();
  }

  async getAccountData() {
    this.setState({
      id: 123,
      name: "Jacob"
    });
  }

  render() {
    return (
      &amp;lt;UserContext.Provider value={this.state}&amp;gt;
          &amp;lt;Account /&amp;gt;
      &amp;lt;/UserContext.Provider&amp;gt;
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Account.js:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Account extends React.Component {
  static contextType = UserContext;

  render() {
    return (
      &amp;lt;UserContext.Consumer&amp;gt;
      {user =&amp;gt; (
      &amp;lt;div className="account"&amp;gt;
          &amp;lt;p&amp;gt;{user.id} - {user.name}&amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
      )}
      &amp;lt;/UserContext.Consumer&amp;gt;
    )
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The user.id variable remains an empty string! I tried to manually change this.context, but this also does not work, it makes a copy as it goes. In addition, there is nothing about this in the documentation. &lt;br&gt;
Any help?&lt;/p&gt;

</description>
      <category>react</category>
    </item>
  </channel>
</rss>
