News for hackers. Stuff that matters.
Re:Redux – Not Dead Yet by hestefisk on Tuesday April 24, 2018 @11:07PM (#16918372)
Context to me seems like a sophisticated way of declaring global variables. Might as well do const GLOBALS = { ... } instead of another complex API that has to be loaded.
Re:Redux – Not Dead Yet by eropple on Wednesday April 25, 2018 @12:26AM (#16918620)
It's not, though, any more than dependency injection is "declaring global variables".
Re:Redux – Not Dead Yet by crooked-v on Wednesday April 25, 2018 @01:14AM (#16918780)
The new context API effectively makes variables available globally, but you're still using a separate (explicitly declared) Consumer for each, so you don't have any of the basic issues that go with using a single set of globals.

For a very simple example:

    import { UserIdConsumer } from '@/contexts'

    const ThisComponent = () => (
      <div>
        User ID: <UserIdConsumer>{value => value}</UserIdConsumer>
      </div>
    )

    export default ThisComponent
Re:Redux – Not Dead Yet by hestefisk on Wednesday April 25, 2018 @04:19AM (#16919523)
Not sure I follow. Where does value come from?
Re:Redux – Not Dead Yet by tym0 on Wednesday April 25, 2018 @08:53AM (#16921042)
UserIdConsumer will call the children prop as function, UserIdConsumer could look like this:

    const UserIdConsumer props => <Fragment>props.children(theValueYouWantAvailable)</Fragment>