r/reactjs • • Nov 01 '18

Needs Help Beginner's Thread / Easy Questions (November 2018)

Happy November! πŸ‚

New month means new thread 😎 - October and September here.

I feel we're all still reeling from react conf and all the exciting announcements! πŸŽ‰

Got questions about React or anything else in its ecosystem? Stuck making progress on your app? Ask away! We’re a friendly bunch. No question is too simple. πŸ€”

πŸ†˜ Want Help with your Code? πŸ†˜

  • Improve your chances by putting a minimal example to either JSFiddle or Code Sandbox. Describe what you want it to do, and things you've tried. Don't just post big blocks of code!
  • Pay it forward! Answer questions even if there is already an answer - multiple perspectives can be very helpful to beginners. Also there's no quicker way to learn than being wrong on the Internet.

New to React?

πŸ†“ Here are great, free resources! πŸ†“

40 Upvotes

377 comments sorted by

View all comments

Show parent comment

1

u/timmonsjg Nov 20 '18

Can you put a minimal example in a codesandbox or something similar?

1

u/seands Nov 20 '18

When I reduced it to a single component the problem did not appear.

I guess I'll git commit and try to remove everything I can

1

u/seands Nov 20 '18 edited Nov 20 '18

ok. props.dispatch_log_to_console_function() doesn't work. It does work when placed inside a button in App.js and called using this.props.dispatch_log_to_console_function()

export default (props) => {
  const save_donation_amount = (e) => {
    props.dispatch_log_to_console_function();
  };

  return (
    <React.Fragment>
       <Button
          onClick={(e) => save_donation_amount(e)}>Next Step
       </Button>
    </React.Fragment>
  )
}
TypeError: props.dispatch_log_to_console_function is not a function
save_donation_amount
src/components/SelectDonation.js:16
 
> 16 | props.dispatch_log_to_console_function();
     | ^  17 | props.dispatch_set_donation_amount(e.target.value);
  18 | console.log(store.getState().donation_amount);
  19 | 

The props object isn't passing to this component for some reason

1

u/seands Nov 20 '18

I put {console.log(props)} in the return of this presentational component and it logged {}

Here are my imports, am I missing something:

import React from "react";
import {css} from "emotion";
import {Button, Modal, Form, Input, Radio} from 'semantic-ui-react';
import store from "../reducer";

1

u/timmonsjg Nov 20 '18

I can't help you without having somewhat of a minimal example in an online editor. You're pasting snippets of code all over and I don't know how they relate.